I have created a callback to handle Window procedures. Everytime that a click a mouse button for instance, I would like to send this message to several classes, so which class can handle it differently depending on its own need. I would like this to be cross platform if possible, but Windows only would be appreciate as well.
CGui * gui;
gui = new Gui();
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
case WM_LBUTTONDOWN:
{
// how to send that a left button was pressed to CGui class ?
// is there another way than gui->LeftButtonPressed = true;
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
Answering my own question :
I believe the "solution" that you guys are talking about is :
case WM_NCCREATE:
{
CREATESTRUCT * pcs = (CREATESTRUCT*)lParam;
CGui * pCGui = (CGui*)pcs->lpCreateParams;
pCGui->m_hWnd = hwnd;
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)pcs->lpCreateParams);
CGui * pCGui = (CGui*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
break;
}
But actually since I need to upgrade several (as I mentioned) classes, the right solution would be the classes to access the WndProc as :
gui->handleMessages(window->hWND, window->message, window->wpParam,
window->lpParam);
And add at the original WndProc :
message = uMsg;
wpParam = wParam;
lpParam = lpParam;
Thanks anyway.