Hi everybody.
As many of you will know, windows move/resize events use their own message pumps, effectively blocking the host application until the operation has completed.
To keep animations running in the background we have to use SetTimer/KillTimer to keep things ticking over.
This works well, except for when the user mouse-downs on a window caption without moving the mouse.
In this case there's an annoying 500ms delay right after windows sends a WM_SYSCOMMAND with (SC_MOVE|HTCAPTION).
These upstanding citizens on gamedev.net noticed that the handler was waiting (WaitForSingleObject style) for a mouse/keyboard message to come in...
Magically, if we push a mouse-move message into the queue just before syscommand comes in, everything just works:
switch (msg) {
case WM_NCLBUTTONDOWN:
if (SendMessage(hWnd, WM_NCHITTEST, wParam, lParam) == HTCAPTION) {
POINT point;
GetCursorPos(&point);
ScreenToClient(hWnd, &point);
PostMessage(hwnd, WM_MOUSEMOVE, 0, point.x | point.y << 16);
}
break;
case WM_ENTERSIZEMOVE:
SetTimer(hWnd, 1, 0, NULL);
return 0;
case WM_EXITSIZEMOVE:
KillTimer(hWnd, 1);
return 0;
case WM_TIMER:
UpdateAndRedraw()
return 0;
case ...
}
There must be some other people out there as anal/petty as I am...