[RESOLVED] SetFocusRect with CheckBox (no .rc file). How to?
Can't seem to infer how to get a focusrect (dotted-line rectangle) around a WinAPI checkbox.
Have tried DrawFocusRect() and also SendMessage() using SET_FOCUS. Maybe I got some parameters wrong? Am still unsure as to what is the accurate HDC to provide to DrawFocusRect.
What code accomplishes this and where in the Window Proc list should it be placed?
How do I determine the correct HDC to provide as the first parameter in DrawFocusRect().
Do I need to use BeginPaint() and EndPaint() around DrawFocusRect()?
Where do I place DrawFocusRect() in Window Procedure to make it affect the checkbox?
If it isn't DrawFocusRect() or SendMessage (supplying WM_SETFOCUS and BST_FOCUS) then how do I get the checkbox to be framed by a dotted-line rectangle?
Appreciate your help, have tried loads of searching on the topic with no answer so far...
Re: SetFocusRect with CheckBox (no .rc file). How to?
Answering my own question here, heheh:
Quote:
How do I determine the correct HDC to provide as the first parameter in DrawFocusRect().
Use GetDC(the Checkbox's HWND);
Re: SetFocusRect with CheckBox (no .rc file). How to?
Aaaaaand, it turns out the Checkbox automatically draws a focus rect when clicked on or when highlighted with tab.
I just had a background that made it impossible to see the focus rect...
For DrawFocusRect() the following parameters give an accurate HDC...
DrawFocusRect(GetDC(HWND), &rectStruct);
Guess I solved my own question...
Re: [RESOLVED] SetFocusRect with CheckBox (no .rc file). How to?
Quote:
Guess I solved my own question...
Great! :)
Re: [RESOLVED] SetFocusRect with CheckBox (no .rc file). How to?
Re: SetFocusRect with CheckBox (no .rc file). How to?
Quote:
Originally Posted by
Arianax
...
DrawFocusRect(GetDC(HWND), &rectStruct);
Guess I solved my own question...
You did, however, only partially.
According MSDN documentation after you called and used GetDC() you then must call ReleaseDC function