Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable the Caps Lock warning with a password control?

Tags:

c#

.net

windows

I get this when I have Caps Lock on with a password control in focus. I would like to add my own warning instead. How can I disable this one? I don't mind P/Invoke or any native code but it has to be in C#.

enter image description here

like image 890
Phoenix Logan Avatar asked Jan 09 '13 17:01

Phoenix Logan


2 Answers

In your form, override WndProc like so, which will intercept the EM_SHOWBALOONTIP message and prevent the control from receiving it:

protected override void WndProc(ref Message m)
{
  if (m.Msg != 0x1503) //EM_SHOWBALOONTIP
     base.WndProc(ref m);
}
like image 137
jlew Avatar answered Oct 16 '22 03:10

jlew


The following code works for me, on the KeyDown event of a TextBox:

    private void txtPassword_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyData == Keys.CapsLock)
        {
            e.SuppressKeyPress = true;
        }
    }
like image 24
Alexander Avatar answered Oct 16 '22 04:10

Alexander