I have a few questions regarding the Windows procedure and how to properly manage messages.
1) What's the difference between handling messages in the example:
while(!exitGame)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
switch(msg.message)
{
case WM_KEYDOWN:
keyboard.UpdateKey(msg.wParam, true);
break;
}
}
Compared to handling it in the WindowProc method
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_KEYDOWN:
keyboard.UpdateKey(msg.wParam, true);
break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
My first guess is that in the WindowProc is that it handles it per-window?
2) For an application that's only dealing with 1 window is it okay to just ignore the WindowProc method? My main problem with this is I would like to update my Keyboard input class from within the function, is the only way to get around this to make it a global?
Thanks