• Advertisement
Sign in to follow this  

Keeping things moving during Win32 Move/Resize events

This topic is 939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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) {
		if (SendMessage(hWnd, WM_NCHITTEST, wParam, lParam) == HTCAPTION) {
			POINT point;
			ScreenToClient(hWnd, &point);
			PostMessage(hwnd, WM_MOUSEMOVE, 0, point.x | point.y << 16);
		SetTimer(hWnd, 1, 0, NULL);
		return 0;
		KillTimer(hWnd, 1);
		return 0;
	case WM_TIMER:
		return 0;
	case ...


There must be some other people out there as anal/petty as I am... biggrin.png

Edited by Josian

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement