Print Page | Close Window

CXTPButtonTheme and drawing the focus rect

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=11008
Printed Date: 04 December 2024 at 2:08pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPButtonTheme and drawing the focus rect
Posted By: rdhd
Subject: CXTPButtonTheme and drawing the focus rect
Date 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?



Replies:
Posted By: rdhd
Date 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.



Posted By: rdhd
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net