ShowFocusCues didn't work for me, but this did:
internal class NoFocusTrackBar : System.Windows.Forms.TrackBar
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
public extern static int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
private static int MakeParam(int loWord, int hiWord)
{
return (hiWord << 16) | (loWord & 0xffff);
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
SendMessage(this.Handle, 0x0128, MakeParam(1, 0x1), 0);
}
}
See documentation on WM_UPDATEUISTATE for how this works (basically sending a message to turn the dumb thing off the trackbar gets the focus).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…