When to draw the focus rectangle
-
How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)
-
How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)
The
DRAWITEMSTRUCT
passed toOnDrawItem()
contains this information. Specifically, theitemState
member, whoseODS_FOCUS
bit indicates the item has focus. You may also want to check theODS_SELECTED
bit to render the control appropriately. See this[^] MSDN article. Alternatively, you could callGetFocus()
to determine if the control has focus, although the preferred way is to check theDRAWITEMSTRUCT
. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)
Send the dialog or button a
WM_QUERYUISTATE
message and test the return value for theUISF_HIDEFOCUS
andUISF_HIDEACCEL
flags. --Mike-- LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD