Windows:在窗口装饰上按下鼠标
在几乎所有 Windows 应用程序中,我注意到在非客户区域按住鼠标按钮会导致绘画停止。 为什么需要这样做?
例如,我有一个 Managed Direct 3D 应用程序,它显示一个旋转的立方体。 如果我将指针放在标题栏上并按住鼠标按钮,立方体就会停止旋转,即使我没有将任何此类条件编码到循环中。
绘画为何停工? 有什么好处? 最重要的是,我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您单击标题栏时,会出现短暂的暂停,同时窗口管理器尝试确定您是否正在单击或开始拖动(移动窗口)。 如果您仍然按住该按钮,那么这就是一种拖动:窗口管理器会设置自己的消息循环并泵送消息,直到您释放鼠标为止。 您的窗口应该仍然能够处理消息,因为它们仍然会被调度,但是如果您的动画依赖于自定义消息循环,那么您将被卡住,直到模态拖动循环结束。
通过触发动画来响应消息来解决这个问题:计时器对我来说似乎是一个不错的选择。
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.