简体   繁体   中英

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.

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. 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

在此处输入图片说明

As for mouse hovering we have BCN_HOTITEMCHANGE event which get triggered and we can handle mouse entering and leaving. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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