I have a feeling the answer to this will teach me something, so I'd be grateful if someone has an answer. Why does the program let the WM_LBUTTONDOWN switch case handle a WM_KEYDOWN message and why is it being handled in that switch statement when there is a perfectly good switch statement prior to it that should handle it. The close button is still handled, so I know it is entering the first switch statement.
I suspect I'm just not understanding the whle concept, so I did dig out an DirectX book to see how they did things, and their code was almost identical to mine - minus the test conditions! Been reading topics on here and MSDN all day, and I have no idea what is going on.
Confused!
LRESULT CALLBACK winProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// check message on queue (if any)
switch (message)
{
case WM_KEYDOWN: // if keystroke registered
switch(wParam) // switch key
{
case VK_ESCAPE: // if escape key
PostQuitMessage(0); // post WM_QUIT message to threads message queue
break;
case WM_DESTROY: // if close button clicked
PostQuitMessage(0); // post WM_QUIT message to threads message queue
break;
default:
break;
}
case WM_LBUTTONDOWN: // if left-click registered
if (wParam == MK_LBUTTON) // and wParam is left-click
{
// test code: increases window by 250px in every direction
width+=500;
height+=500;
SetWindowPos(wndHandle, HWND_TOP, (GetSystemMetrics(16)-width)/2,
(GetSystemMetrics(17)-height)/2, width, height, SWP_SHOWWINDOW);
}
break;
case WM_RBUTTONDOWN: // if right-click registered
if (wParam == MK_RBUTTON) // and wPparam is right-click
{
// test code: decreases window by 250px in every direction
width-=500;
height-=500;
SetWindowPos(wndHandle, HWND_TOP, (GetSystemMetrics(16)-width)/2,
(GetSystemMetrics(17)-height)/2, width, height, SWP_SHOWWINDOW);
}
break;
default:
break;
}
// return message to default window procedure for handling
return DefWindowProc(hWnd, message, wParam, lParam);
}