-
problem
i have just started to write an window class... blah blah
the class looks like this:
class WINDOW
{
private:
WNDCLASS WndClass;
public:
void Create(/*some stuff*/);
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam, LPARAM lParam);
// and some more stuff
};
and here is the problem in create:
void Create(/*some stuff*/)
{
// some ****
WndClass.lpfnWndProc = /*some thing to set the correct wndproc*/
}
if i move WndProc outside the class all works fine and i only need
to do like this: WndClass.lpfnWndProc = WndProc;
but when WndProc is in my class msvc complains about that
iam doing an illegal type cast.
isnt this possible to do?
please need help
//xfish
-
You'll have to make your WndProc a static method. This static function can then call a non-static version of your WndProc if you pass the 'this' pointer in as the extra window creation data in your call to CreateWindow(). You can then extract the 'this' pointer in your static WndProc using GetWindowLong() and use it to call the non-static version (passing the parameters along).