1、工具栏、菜单栏按钮消息,即所谓的命令消息,它们的消息传递的方式是拐弯上溯(侯俊杰老师的说法),消息会先到view那里,这里view就是MFC的活动视图,用SetActiveView来设置。
2、鼠标、键盘消息是一般windows消息,它们消息传递的方式是直线上溯。其中,滚轮、键盘消息会传到拥有Focus的视图那里,用setfocus来设置,如果没有设置Focus,则会传到ActiveView那里;单击、双击、右键等消息会传到拥有Capture的试图那里,用SetCapture来设置,如果没有设置,则会到WindowFromPoint(获取包含指定点的窗口的句柄)那里。
一下是MSDN的定义:
其实看下MSDN的定义就知道了
他们都还是有区别的
SetCapture
This function sets the mouse or style capture to a specified window that belongs to the current thread. After you call this function for a window, the window captures mouse input that occurs while the mouse cursor remains within the window. The window also captures mouse input that occurs when the user presses a mouse button while the mouse cursor is located within the window and continues to hold the mouse button down while moving the mouse. Only one window at a time can capture the mouse or stylus.
SetFocus Function
The SetFocus function sets the keyboard focus to the specified window. The window must be attached to the calling thread's message queue.