Sometimes messages generate other messages as a result of DefWindowProc processing. For example, suppose you run HELLOWIN and you eventually click the Close button, or suppose you select Close from the system menu using either the keyboard or the mouse. DefWindowProc processes this keyboard or mouse input. When it detects that you have selected the Close option, it sends a WM_SYSCOMMAND message to the window procedure. WndProc passes this message to DefWindowProc. DefWindowProc responds by sending a WM_CLOSE message to the window procedure. WndProc again passes this message to DefWindowProc. DefWindowProc responds to the WM_CLOSE message by calling DestroyWindow. DestroyWindow causes Windows to send a WM_DESTROY message to the window procedure. WndProc finally responds to this message by calling PostQuitMessage to put a WM_QUIT message in the message queue. This message causes the message loop in WinMain to terminate and the program to end. 其中,When it detects that you have....中的it指的是windows还是defwndproc?
WM_SYSCOMMAND是进消息队列?还是直接发给wndproc?
这个问题困扰我多时,请问有什么样的方法设置断点来调试?看清楚消息走向,或者程序流程?Sometimes messages generate other messages as a result of DefWindowProc processing
这句话如何理解,是DefWindowProc直接产生消息发送给wndproc?还是产生消息发给windows,然后由windows发给wndproc?谢谢大家!

解决方案 »

  1.   

    我的电子版的翻译好像也不怎么样有时候,DefWindowProc处理完讯息後会产生其他的讯息。例如,假设使用者执行HELLOWIN,并且使用者最终单击了 Close 按钮,或者假设用键盘或滑鼠从系统功能表中选择了 Close , DefWindowProc处理这一键盘或者滑鼠输入,在检测到使用者选择了 Close 选项之後,它给视窗讯息处理程式发送一条WM_SYSCOMMAND讯息。WndProc将这个讯息传给DefWindowProc。DefWindowProc给视窗讯息处理程式发送一条WM_CLOSE讯息来回应之。WndProc再次将它传给DefWindowProc。DestroyWindow呼叫DestroyWindow来回应这条WM_CLOSE讯息。DestroyWindow导致Windows给视窗讯息处理程式发送一条WM_DESTROY讯息。WndProc再呼叫PostQuitMessage,将一条WM_QUIT讯息放入讯息伫列中,以此来回应此讯息。这个讯息导致WinMain中的讯息回圈终止,然後程式结束。
      

  2.   

    其实WM_COMMAND消息是不进队列直接发给wndproc的.还有一句, when you select a menu item with the keyboard or mouse, the keyboard or mouse message is queued but the eventual WM_COMMAND message indicating that a menu item has been selected is nonqueued. 其中eventual怎么来的,是先有鼠标消息进消息队列,然后getmessage,然后dispatch消息给windows,然后windows发送WM_COMMAND吗?应该是这样的吧!关键是DefWndProc怎么样处理WM_SYSCOMMAND消息,产生新的消息给windows,还是直接给WndProc??
      

  3.   

    我得出结论了,呵呵, DefWindowProc可以直接产生消息到WndProc!!!!
    类似与SendMessage()