Hiding the dotted pattern around trackball controls when selecting

In C # winforms, is there a way to not show the border of the dashed border of the path that appears around the trackball control when it is in use?

Details: this outline looks sticky to me, so I just shoot aesthetics so as not to show it.

Thanks,

Adam

+3
source share
2 answers

ShowFocusCues did not work for me, but it happened:

   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 the WM_UPDATEUISTATE documentation for how this works (basically sending a message to turn a dumb thing from a trackbar into focus).

+15
source

, , , - :

public class TrackBarWithoutFocus : TrackBar
{
    private const int WM_SETFOCUS = 0x0007;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_SETFOCUS)
        {
            return;
        }

        base.WndProc(ref m);
    }
}
0

Source: https://habr.com/ru/post/1718652/


All Articles