Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows: Mouse Down on Window Decoration

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?

like image 577
Agnel Kurian Avatar asked Oct 27 '08 05:10

Agnel Kurian


1 Answers

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.

like image 101
Shog9 Avatar answered Sep 27 '22 19:09

Shog9