Hello,
I have been studying this 4 part series to get familiar with winapi concepts such as creating windows and message events.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff381399%28v=vs.85%29.aspx
I am struggling to get my head around what is called when, such as at compile time and at run time, when the 'events' are taking place. I have some questions if those more knowledgeable can assist me:
In the simplest of demos, the "hello world" of windows gui programming (located here http://msdn.microsoft.com/en-us/library/windows/desktop/ff381409%28v=vs.85%29.aspx), I just want to ensure I understand what happens at compile time and run time.
Upon first program run, after HWND hwnd = CreateWindowEx() the program jumps to LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam). With a breakpoint at switch(uMsg) which lies in the WindowProc, I see the program do this:
uMsg = 36
program goes to return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 129
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 131
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 1
return DefWindowProc(hwnd, uMsg, wParam, lParam);
program then goes to ShowWindow(hwnd, nCmdShow); Are we at run-time now?
Continuing the step through...
uMsg = 24
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 70
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 70
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 28
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 134
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 127
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 127
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 127
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 6
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 641
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 642
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 7
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 133
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 20
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 71
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 5
return DefWindowProc(hwnd, uMsg, wParam, lParam);
uMsg = 3
return DefWindowProc(hwnd, uMsg, wParam, lParam);
After all of this we FINALLY hit
MSG msg = { };
then
while (GetMessage(&msg, NULL, 0, 0))
it then jumps back to switch(uMsg)
uMsg = 127
return DefWindowProc(hwnd, uMsg, wParam, lParam);
3 times, then
uMsg = 136
return DefWindowProc(hwnd, uMsg, wParam, lParam);
then off to
TranslateMessage(&msg);
DispatchMessage(&msg);
Then If i keep spamming Continue it seems to keep jumping between the message loop and the WindowProc. This is without me, the user, interacting with the window in any way. (In fact there is no way for me to intact with it except a close, minimise, or resize)
Basically I really want to know what is going on. What do these numbers mean? When I don't use the debugger the window just pops up. So what are all these messages being generated when I'm not touching the window? And what is the distinction between run-time and compile time with win32 programs?
Thanks. Apologizes for the long post, I just really have to set breakpoints and step through code to understand what is going on, and when its doing all of these mysterious commands I must know why.