Windows 10和WM_QUIT [英] Windows 10 and WM_QUIT

查看:95
本文介绍了Windows 10和WM_QUIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我不确定是否在Windows 7和Windows 10之间发现了窗口消息行为的变化。

Hello, I am not sure if I have found a change in window message behavior between Windows 7 and Windows 10.

我正在使用GetMessage()来处理消息我的消息循环,我的WM_CLOSE和WM_DESTROY处理看起来像这样。

I am using GetMessage() to handle messages in my message loop, and my WM_CLOSE and WM_DESTROY processing looks like this.

当使用GetMessage文档中的示例时,while循环检查结果是否为0,即WM_QUIT消息未到达。现在奇怪的是窗口被破坏导致GetMessage失败,然后收到任何
WM_QUIT。这使得应用程序处于spinlook中,因为GetMessage()结果将始终为-1。

When using the example from the documentation of GetMessage the while loop checks to see if the result is not 0, i.e a WM_QUIT message has not arrived keep going. Now the wierd thing is that the window gets destroyed causing GetMessage to fail before any WM_QUIT gets recieved. This leaves the application in a spinlook since the GetMessage() result will always be -1.

我知道我可以改为始终查找Result> 0但我觉得我在这里遗漏了一些东西。

I know I can just change to always look for Result > 0 but I feel like I am missing something here.

使用Spy ++时,我从来没有看到我的应用程序或记事本的WM_QUIT。

When using Spy++ I never see a WM_QUIT for my app or from notepad.

推荐答案

DestroyWindow的Window参数是否为有效的HWND? 在处理WM_CLOSE后,Window过程是否返回0?

Is the Window parameter to DestroyWindow a valid HWND?  Is the Window procedure returning 0 after handling WM_CLOSE?

尝试注释掉WM_CLOSE处理程序并让DefWindowProc为您调用DestroyWindow。

Try commenting out the WM_CLOSE handler and let DefWindowProc take care of calling DestroyWindow for you.


这篇关于Windows 10和WM_QUIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆