I'm encountering following problem in my MFC application:
The focus rectangle in controls is not always showing up, even if the control has the focus.
Steps to reproduce:


It's like there were two "modes" one where focus rectangles are shown and one where they are not shown.
Other facts:
Has anybody encountered such a problem? I wonder if this is some "clever" Microsoft feature.
This is a Windows feature known as "Keyboard Cues" (SPI_GETKEYBOARDPREF and SPI_GETKEYBOARDCUES) and newer versions of Windows defaults to hiding them (focus rectangle and underlined keyboard access keys) in dialog based windows. This feature was introduced in Windows 2000.
The Windows dialog manager initializes dialogs based on the last input (mouse or keyboard):
The default state for a window is to show all indicators. But as a special trick, the dialog manager will send a WM_UPDATEUISTATE message with UIS_INITIALIZE after the dialog has been initialized, which turns off the indicators if the last input event was a mouse event.
You can post a WM_UPDATEUISTATE message to your dialog window with MAKELONG(UIS_CLEAR, UISF_HIDEFOCUS) to display the focus rectangle (if you wish to override the Windows defaults).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With