none
How do I re-enable focus rectangles for buttons with the BS_AUTOCHECKBOX and BS_RADIOBUTTON Styles w/ Common Controls 6.0

    Question

  • Environment: Windows 7, Common Controls 6.0, Visual Studio 2010, C and Win32

    User-developed applications authored using our product  (an IDE named OpenROAD 6.2) no longer show focus rectangles when Buttons with the BS_AUTOCHECKBOX and BS_RADIOBUTTON take focus.  Changing the Theme from Aero to Classic resolves this

    Our product (OpenROAD 6.2) requires Common Controls 6.0 to get the Windows 7 look and feel, however the buttons not displaying focus rectangles is causing our customers grief.

    How can I, for Buttons only, re-enable the focus rectangle behavior we used to see.  Is this a system setting or do I need to do this in C code (if so an example/sample would be perfect!).

    Thanks!



    • Edited by D Criley Thursday, July 21, 2016 10:22 PM
    Thursday, July 21, 2016 6:47 PM

Answers

  • I have found the solution to my  problem.

    When we first started to modify our controls (which for the most part derived from Microsoft controls) to take advantage of Common Controls 6.0 (and Themes) we found we lost some functionality within our product.  An example being not being able to change the text color for RadioButtons and Checkboxes.  Microsoft suggested a remedy; using the CustomDraw/WM_NOTIFY feature to set the text color when the WM_NOTIFY message is for an item to be painted is in the CDDS_PREPAINT stage, drawing the text using DrawText, then returning from the callback with a return status set to CDRF_SKIPDEFAULT.

    Using this technique (which returns CDRF_SKIPDEFAULT to the caller) was causing Focus rectangles to no longer be painted.  The reason the rectangles where not painted was the CDRF_SKIPDEFAULT return status.  When, in the process of handling the WM_NOTIFY message, we check  custom draw structure ( passed as a LPNMCUSTOMDRAW in the message's lParam argument ) and check the uItemState attribute for a CDIS_FOCUS state.  If the state is CDIS_FOCUS, we need to return a CD_RFDODEFAULT status.

    • Marked as answer by D Criley Thursday, August 04, 2016 3:04 PM
    Thursday, August 04, 2016 3:04 PM

All replies

  • >User-developed applications authored using our product product (an IDE named OpenROAD 6.2) no longer show focus rectangles when Buttons with the BS_AUTOCHECKBOX and BS_RADIOBUTTON take focus.

    Do they look any different from buttons with those styles authored
    with straight Win32?

    Do you not get any focus indication if you active the UI by keyboard
    operations rather than the mouse - or by pressing the Alt key when
    focus is inside a dialog with those buttons?

    Dave

    Thursday, July 21, 2016 11:29 PM
  • We use Win32 strictly.  With the BS_AUTOCHECKBOX and BS_RADIOBOX style we have subclassed the controls based on the Win32 Button class.  In both cases the WS_SETFOCUS messages are being passed directly to the Button control with absolutely no action being taken by the subclasses.  As far as the UI is concerned, the problem occurs when using TAB/SHIFT-TAB to move from one field to another. 

    I added "SetWindowTheme( hwnd, L"", L"")" calls just after the "CreateWindow" calls and the desired focus rectangle behavior was restored.  The problem, if there is one, is that now all things related to control themes for these buttons are ignored.  Is there a way to ignore themes only for focus rectangles?

    • Edited by D Criley Monday, July 25, 2016 5:42 PM
    Monday, July 25, 2016 2:37 PM
  • Start from a minimal Win32 application generated by VS and see if you
    can reproduce the problem.

    If you can, what did you have to change?

    Dave

    Monday, July 25, 2016 8:34 PM
  • Unfortunately our VS is 2010, and when we use it to author and build Win32 applications,  they do not use Common Controls 6.0 (I created an app as you suggested).  We have are own make files and source build framework. It is responsible for building Common Controls 6-based Win32 applications.

    In the past, with Common Controls 6.0, we had a problem setting the text color of a checkbox. Microsoft suggested using Custom Draw and changing the text color at the CDDS_PREPAINT stage.  That worked as expected.

    Tuesday, August 02, 2016 9:13 PM
  • >Unfortunately our VS is 2010, and when we use it to author and build Win32 applications,  they do not use Common Controls 6.0 (I created an app as you suggested).

    If you create a Unicode application, and it has the correct manifest
    information, it should use V6 common controls.

    Dave

    Tuesday, August 02, 2016 11:09 PM
  • Thanks!
    Wednesday, August 03, 2016 2:54 PM
  • Hi D Criley,

    If any replies are helpful for you, would you please make it as the answer? So it would be helpful for other members who meet the same issue, and I could close this case for you.

    Thank you for your support and co-operation.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 04, 2016 12:20 PM
    Moderator
  • I have found the solution to my  problem.

    When we first started to modify our controls (which for the most part derived from Microsoft controls) to take advantage of Common Controls 6.0 (and Themes) we found we lost some functionality within our product.  An example being not being able to change the text color for RadioButtons and Checkboxes.  Microsoft suggested a remedy; using the CustomDraw/WM_NOTIFY feature to set the text color when the WM_NOTIFY message is for an item to be painted is in the CDDS_PREPAINT stage, drawing the text using DrawText, then returning from the callback with a return status set to CDRF_SKIPDEFAULT.

    Using this technique (which returns CDRF_SKIPDEFAULT to the caller) was causing Focus rectangles to no longer be painted.  The reason the rectangles where not painted was the CDRF_SKIPDEFAULT return status.  When, in the process of handling the WM_NOTIFY message, we check  custom draw structure ( passed as a LPNMCUSTOMDRAW in the message's lParam argument ) and check the uItemState attribute for a CDIS_FOCUS state.  If the state is CDIS_FOCUS, we need to return a CD_RFDODEFAULT status.

    • Marked as answer by D Criley Thursday, August 04, 2016 3:04 PM
    Thursday, August 04, 2016 3:04 PM