class CApplication
{
public:
bool Update();
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
CApplication(HINSTANCE hInstance);
virtual ~CApplication();
private:
CGame m_Game;
MSG m_Msg;
HINSTANCE m_hInstance;
HWND m_hWnd;
};
the message procedure
I''m trying to make an application class that''ll encapsulate all of the windows programming stuff for my game...
In the constructor I fill in the windows class structure and register it and create the window and stuff. The only problem is when I''m saying what the message procedure will be...
wc.lpfnWndProc = WndProc;
It tells me
C:\code\msvc\DirectX Wrapper\Application.cpp(24) : error C2440: ''='' : cannot convert from ''long (__stdcall CApplication::*)(struct HWND__ *,unsigned int,unsigned int,long)'' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)''
There is no context in which this conversion is possible
I know this is because WndProc is a member of my class, but what can I do about it? I tried changing it to CApplication::WndProc, and that doesn''t work either. How would I do this?
- f l u c k y p o o
- the geek inside
- f l u c k y p o o
Short answer: Read the bloody FAQ. This question gets asked all the time, and is explained in the FAQ.
Another short answer: The WndProc function cannot be a class-member. Only way you can do what you ask is make your WndProc method static to the class.
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
Another short answer: The WndProc function cannot be a class-member. Only way you can do what you ask is make your WndProc method static to the class.
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
quote: Original post by Neophyte
Only way you can do what you ask is make your WndProc method static to the class.
Not exactly true, because you can also go the way they did with ATL (much longer and more complex but works.... use the Search tool)
I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
I stand partially corrected.
I am not fully intimate with the implementation details of ATL, but from what I can gather from looking at the atl headers it is both excessively complex, and basically looks like cheating, since several of the atl classes contains static references to WndProc methods anyway.
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
I am not fully intimate with the implementation details of ATL, but from what I can gather from looking at the atl headers it is both excessively complex, and basically looks like cheating, since several of the atl classes contains static references to WndProc methods anyway.
-Neophyte
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+
----- END GEEK CODE BLOCK-----
geekcode.com
I dont use ATL but it''s pretty interesting how they did it =)
I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement