windows中WM_CLOSE消息和WM_DESTORY消息的不同之处

本文解析了WM_CLOSE和WM_DESTROY两个Windows消息的作用及区别。WM_CLOSE仅表示关闭指令,开发者可以选择忽略或通过调用DestroyWindow处理;而WM_DESTROY则在窗口实际销毁时触发,之后窗口将不再存在。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、WM_CLOSE仅代表用户发出了关闭的指令,但窗口过程可以不理睬该消息,因为怎么处理这个消息完全由自己决定。
.elseif meax==WM_CLOSE
invoke DestroyWindow,hwinmain ;销毁窗口
invoke PostQuitMessage,Null ;向消息循环中发出退出消息
如果在这里不调用DestroyWindow,窗口是不会自动销毁的
但如果把这个消息交给DestroyWindow处理,则By default, the DefWindowProc functioncalls the DestroyWindow function to destroy thewindow.会调用DestroyWindow

2、WM_DESTROY
MSDN:
The WM_DESTROY message is sent when a window is being destroyed. Itis sent to the window procedure of the window being destroyed afterthe window is removed from the screen.

This message is sent first to the window being destroyed and thento the child windows (if any) as they are destroyed. During theprocessing of the message, it can be assumed that all child windowsstill exist.
当窗口正在关闭时发送该消息,当窗口从屏幕移除后,窗口正在销毁时,发送给窗口过程的,并且将子窗口一起销
毁。
A window receives this message through its WindowProcfunction.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值