Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - CXTPButtonTheme and drawing the focus rect
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPButtonTheme and drawing the focus rect

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: CXTPButtonTheme and drawing the focus rect
    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_SHOWFOCUS

When 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?
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 14 June 2008 at 2:47pm

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.

Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2008 at 9:25am
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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.