Jump to content
  • Advertisement
Sign in to follow this  
Josian

Keeping things moving during Win32 Move/Resize events

This topic is 1021 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) {
	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... biggrin.png

Edited by Josian

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!