SetFocus、SetCapture和SetActiveView 区别

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值