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

阅读更多

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.

 

你可能感兴趣的:(Windows)