CXTPButtonTheme and drawing the focus rect |
Post Reply |
Author | |
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
Posted: 12 June 2008 at 1:03pm |
I have a button subclassed from the CXTButton. I set the style using SetXButtonStyle to
BS_XT_WINXP_COMPAT |BS_XT_HILITEPRESSED|BS_XT_TWOROWS|BS_XT_SHOWFOCUSWhen asked to display a button with focus, sometimes I get the focus rect drawn and sometimes not. Stepping thru the button theme drawing code I see that when it fails to draw, the ODS_NOFOCUSRECT style bit is set in the input item structure (ODS_FOCUS is set - the ODS style is 0x310). I also verified that this happens on the same same button ("this" is the same so it is not another button object).
Also, once the focus draws (the ODS_NOFOCUSRECT bit is not set), from then on the button will draw with focus anytime I set focus to the button.
So far, the most reliable way for me to get that style removed is to tab to the button (SetFocus is called) and then hit the spacebar. The button presses and from then on when I tab to the button the rect draws.
In order to "fix" this, I overrode DrawItem and zap that bit and then send the call to CXTButton. That seems like a kludge to me.
My only questions are:
How does the ODS_NOFOCUSRECT style gets set in the owner draw structure to begin with?
What would cause it to disappear? |
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
I have found that I can do this to a dialog box to get rid of the no focus style: SendMessage ( WM_CHANGEUISTATE, MAKELONG( UIS_CLEAR, UISF_HIDEFOCUS ), 0 );I still don't know what sets the UI state so the no focus state exists but at least I can zap the thing. |
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
Make that a WM_UPDATEUISTATE instead of WM_CHANGEUISTATE. The latter causes windows to send the same message to all the windows in my process.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |