简体   繁体   English

是否有任何事件可以吸引人们关注MFC中的按钮控件?

[英]Is there any event to capture focus on a button control in mfc?

Basically now I am loading bitmap on a button as of four states as follows: 现在,基本上,我正在按以下四种状态在按钮上加载位图:

cases: 案例:

  1. When I launch my application initially the buttons are being loaded with a bitmap. 最初启动应用程序时,按钮会加载位图。
  2. When mouse hovering I am loading another bitmap. 当鼠标悬停时,我正在加载另一个位图。
  3. And similarly loading bitmap on button click. 同样,在单击按钮时加载位图。
  4. Finally fourth state is when I click tab the focus keeps on changing from one control to another, with rectangular dotted line . 最后的第四个状态是,当我单击选项卡时,焦点一直在用矩形虚线从一个控件切换到另一个控件。

In the case4 I want to load one more bitmap when the button control gets the rectangular focus and should load another bitmap if once the button looses the focus. case4当按钮控件获得矩形焦点时,我想再加载一个位图;如果按钮失去焦点,则应该加载另一个位图。

I googled for long time and I did not get any clue to resolve this issue. 我搜索了很长时间,但没有任何线索可以解决此问题。

Initially, when I run my application it as follows: 最初,当我运行我的应用程序时,它如下:

在此处输入图片说明

Once when I click Tab the rectangular selection moves on to the button. 单击“ Tab ,矩形选择将移至该按钮。 Now, when the button control receives that rectangular focus I have to load a bitmap and when the button leaves focus I need to load another bitmap. 现在,当按钮控件接收到矩形焦点时,我必须加载一个位图,而当按钮离开焦点时,我需要加载另一个位图。

After Tab click Tab

在此处输入图片说明

As for mouse hovering we have BCN_HOTITEMCHANGE event which get triggered and we can handle mouse entering and leaving. 至于鼠标悬停,我们有触发的BCN_HOTITEMCHANGE事件,我们可以处理鼠标的进入和离开。 Similar to this do we have any which gets triggered when it receives are looses the focus? 与此类似,当接收到的内容失去焦点时,是否触发了任何触发?

Can anyone please help me to resolve this issue. 谁能帮我解决这个问题。

To be honest I'm not entirely sure what you're trying to do. 老实说,我不确定您要做什么。 But if the button has the BS_NOTIFY window style set, its parent window will get a WM_COMMAND message with the HIWORD set to BN_SETFOCUS when the button gains focus, and BN_KILLFOCUS when it loses it. 但是,如果按钮具有BS_NOTIFY窗口样式集,它的父窗口将得到一个WM_COMMAND消息的HIWORD设置为BN_SETFOCUS当按钮获得焦点, BN_KILLFOCUS当它失去它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM