how can i use a WndProc from a class (for use in WNDCLASSEX)?
i have tried to use a static (global) SWndProc and it will return ActiveWindow->WndProc() (ActiveWindow is the current active Window class)
but it doesn't seems to work.
SWndProc:
static LRESULT CALLBACK SWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_SYSCOMMAND:
case WM_PAINT:
case WM_CLOSE:
case WM_DESTROY:
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
if (&ActiveWindow)
return ActiveWindow->WndProc(hwnd,msg,wParam,lParam);
return 0;
}
RegisterClassEx:
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = SWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpszClassName = title.c_str();
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wc))
{
r=0;
goto RETURN;
}
and i get an access violation and error code 2(GetLastError(), 2 means: "The system cannot find the file specified.")..its probably because SWndProc.
i remember that in past, i changed many things (in switch(msg)) and i didnt get access violation..
how can i handle more than one WndProc for using multiple windows and each window will have a different 'main loop', or it is done in an other way?
thanks,
pex.