PDA

View Full Version : win32 and C++ question - please...



lsdi
06-23-2002, 08:04 PM
Please help me...


Im trying to put the CALLBACK function inside a c++ class, but Im try to use:




...
hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) this->WndProc;
...


I get this error:

error C2440: '=' : cannot convert from 'long (__stdcall MyClass::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'


Definitions:




class MyClass {
public:
LRESULT CALLBACK WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
}

LRESULT CALLBACK MyClass::WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
return 0;
}



[This message has been edited by lsdi (edited 06-23-2002).]

[This message has been edited by lsdi (edited 06-23-2002).]

coredump
06-23-2002, 08:17 PM
this may work

make your WndProc() function static then use this:



...
wc.lpfnWndProc = (WndProc)MyClass::WndProc;
...


b

[This message has been edited by coredump (edited 06-23-2002).]

lsdi
06-23-2002, 08:43 PM
Great!!! Working now.

thanks a lot