views:

310

answers:

1

In almost any Windows application, I notice that holding the mouse button down in a non-client area causes the painting to stop. Why is this required?

For example, I have a Managed Direct 3D application which displays a spinning cube. If I place the pointer over the title bar and hold the mouse button down, the cube ceases to spin even though I have not coded any such condition into my loop.

Why is painting halted? What are the benefits? Most importantly, how can I work around this?

+4  A: 

When you click on the title bar, there's a brief pause while the window manager tries to determine whether or not you're clicking or beginning a drag (moving the window). If you're still holding down the button, then it's a drag: the window manager sets up its own message loop and pumps messages until you release the mouse. Your window should still be able to process messages, because they'll still be dispatched, but if your animation depends on a custom message loop then you'll be stuck 'till the modal drag loop ends.

Work around it by triggering your animation in response to messages: a timer seems like a good choice to me.

Shog9
Just want to clarify that my application does not depend on a custom message loop. Also, I believe this conditions applies to all applications on Windows XP (and 2000... have not tested on others).
Vulcan Eager