Nevermind, I figured it out.
Another question. I just noticed that the program is using a lot of cpu when it's just sitting there. A little debug printing showed that the WM_PAINT message is always being sent. I thought that would only be sent if the window needs redrawing. If I comment it out, the CPU usage drops to zero, where it should be. Am I missing something to only make it paint the window when needed?
It does the same thing in a blank Dev-Cpp Win32 Application if I add the WM_PAINT to it. 100% CPU.
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
0% CPU.
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
case WM_PAINT:
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
100% CPU