How to enable block checkers whenever in a text field with significant focus

I have a form with a rich text box. Is there a way to enable cap locking when focus has a lot of control over text fields? And turn it off if the rich text box loses focus? I am using c #

+3
source share
7 answers

I would suggest instead capturing the key input and replacing it with the appropriate uppercase version. Otherwise, imagine a situation where a user presses a text field, switches to another application, implements Caps Lock, throws a brick on his computer out of frustration, and then switches back to your application, where the cursor sits in a text field waiting for uppercase letters, but Caps Lock is now off.

+5
source

. CAPS LOCK , SHIFT (), . , (, ). KeyPress, KeyUp, Ed.C, :

public partial class Form1 : Form
{        
    public Form1()
    {
        InitializeComponent();
        richTextBox1.KeyPress += new KeyPressEventHandler(richTextBox1_KeyPress);            
    }

    void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        e.KeyChar = Char.ToUpper(e.KeyChar);            
    }
}
+4

Win32 API.

, CAPS LOCK, API SetKeyState

[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] 
public static extern short GetKeyState(int keyCode); 

public void getCapsLockState() {
    bool CapsLock = (((ushort) GetKeyState(0x14 /*VK_CAPITAL*/)) & 0xffff) != 0;
}
+2

, , , - JQuery capizer , , , keyup.

, , # String.ToUpper() .

0

, - .. , textchanged .

, - .

0

KeyUp, .Text ToUpper(). .

0

Console.capsLock == true, ,

0

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


All Articles