how to disable System's caps-lock notification

2019-03-05 18:20发布

问题:

In Winforms Textbox, I have defined new ToolTip and configured it. I have set the PasswordChar to '*'. However, when caps lock is on, two tooltip is shown. One of them is mine the other one is system's default tooltip notification. I only want to show my tooltip. I want to disable system's tooltip. How can I disable it?

回答1:

One way is to derive your own textbox control from the existing one and handle the EM_SHOWBALLOONTIP message. Then just drag this control onto your form instead of the regular textbox control.

public partial class PasswordTextBox : TextBox
{
    private const int EM_SHOWBALLOONTIP = 0x1503;

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == EM_SHOWBALLOONTIP)
        {
            m.Result = (IntPtr)0;
            return;
        }
        base.WndProc(ref m);
    }

    public PasswordTextBox()
    {
        InitializeComponent();
    }
}