1

Is there any way to remove the dotted line rectangle, which indicates the keyboard focus, on a Win32 common control, without owner draw or subclass them?

It seems that under WPF one can control the visual style of the focus rectangle, but I failed to find corresponding API on a Win32 common control.

Blair Conrad
  • 233,004
  • 25
  • 132
  • 111
user10697
  • 13
  • 3
  • Solution can be found [here](http://stackoverflow.com/questions/2691726/how-can-i-remove-the-selection-border-on-a-listviewitem). – Axalo Apr 10 '17 at 22:36

2 Answers2

1

You can send it the WM_CHANGEUISTATE message or subclass it and fake the parameters in response to WM_UPDATEUISTATE

Anders
  • 97,548
  • 12
  • 110
  • 164
  • 2
    `SendMessage(main_window, WM_CHANGEUISTATE, (WPARAM) MAKELONG(UIS_SET, UISF_HIDEFOCUS), 0);` worked great for me. All buttons under the main window no longer have the dotted borders. – Joshua Perrett Aug 28 '22 at 03:57
  • Update: dotted borders come back if you start tabbing through controls. :/ – Joshua Perrett Aug 31 '22 at 23:15
  • @JoshuaPerrett Yes, that is by design. They don't if you use the mouse. I'm sure you could try to hide them again on focus changes or subclass to eat the message but why? – Anders Aug 31 '22 at 23:34
0

I don't believe there is a simple style that allows you to turn off the focus rect on a list view control. The only way I've ever seen it done is with an owner draw control. I know this is not the answer you were looking for, but there are examples of owner draw controls that do this available... just so you don't have to do all the work. :)

Kevin
  • 7,856
  • 11
  • 35
  • 40