'Delphi styled VCL TTrackBar: hide focus dotted rectangle while tracking
Solution 1:[1]
Using
SendMessage(tb1.Handle, WM_UPDATEUISTATE, UIS_CLEAR OR UISF_HIDEFOCUS, 0);
does work.
Before
After
Although it is definitely the case that calling:
SendMessage(tb1.Handle, WM_UPDATEUISTATE, UIS_CLEAR OR UISF_HIDEFOCUS, 0);
while the control has focus causes the focus rectangle to temporarily re-appear until it loses focus.
Note: I only tried it with styles enabled.
Solution 2:[2]
You can prevent TTrackBar from getting focused by setting its TabStop property to ?False`.
When you do this the the dotted line around TTrackBar won't ever be shown.
Well the only exception is if you have no other focusable component on the form in which case the dotted line still appears when you start interacting with the trackbar.
EDIT: Right I forgot that VCL Styles override the said property amongst many others.
You could modify your VCL style in a way so you disable the FocusEffect for TTrackBar and then use this modified style instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |



