更新时间:2022-05-15 15:31:28
我不认为你会得到一个单一的消息解决。
I don't think that you get this solved with a single message.
当您关闭应用程序时,您还必须区分鼠标操作和Alt + F4
如果使用Alt + F4关闭应用程序,消息看起来是相同的,如从任务栏关闭它(查看lParam值)
When you Close the application you have to distinguish also between a mouse action and Alt+F4 If you close the application with Alt+F4 the message looks identical like closing it from the task bar (Look at the lParam value)
您可以查看使用GetMessage检索的最后一条消息(最后一条输入消息)。如果消息来自任务栏,它是一个发布的WM_SYSCOMMAND。如果消息来自内部,您会收到WM_SYSCOMMAND作为SendMessage。
You can look at the last message that was retrieved with GetMessage (the last input message). If the message comes from the task bar it is a posted WM_SYSCOMMAND. If the message comes from the inside you receive the WM_SYSCOMMAND as SendMessage.
您可以使用AfxGetCurrentMessage确定最后一个输入消息是什么。如果你在这里找到WM_SYSCOMMAND,关闭来自任务栏。
You can use AfxGetCurrentMessage to determine what was the last input message. If you find WM_SYSCOMMAND here the close comes from the taskbar. If you find a keyboard or mouse message here the message comes form the user input.
提示:使用Spy ++检查此行为。
Tip: Use Spy++ to examine this behavior.