Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Suppress Windows On-screen Keyboard (Read 1878 times)
Art Bragg
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Mar 10th, 2019
Suppress Windows On-screen Keyboard
Mar 10th, 2019 at 8:21pm
Print Post  
Hi - I've implemented an on-screen keyboard using the MindFusion keyboard for my WinForms application and it's a great success - I was able to do everything I wanted to do with it.  My question is - is there any way to suppress the Windows On-Screen keyboard while my app is running?  The app will be running on a small Windows tablet that does not have a hardware keyboard.

Thanks!
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Suppress Windows On-screen Keyboard
Reply #1 - Mar 11th, 2019 at 12:03pm
Print Post  
Sadly there does not seem to exist any API to disable the OSK for specific application or controls. Google shows some suggestions like killing the OSK process or disabling registry settings but that does not sound proper thing to do. I was able to prevent it from appearing with some event handling and toggling the controls' ReadOnly property like this -

Code
Select All
void SetReadOnly(TextBox tb, bool value)
{
    tb.ReadOnly = value;
    tb.BackColor = Color.Black;
    tb.ForeColor = Color.Black;
    tb.BackColor = Color.White;
}

private void Form1_Load(object sender, EventArgs e)
{
    var vk = new MindFusion.UI.WinForms.VirtualKeyboard();
    vk.Dock = DockStyle.Bottom;
    Controls.Add(vk);
    vk.IsStandAlone = false;
    vk.PreventActivation = true;
    //textBox1.AccessibleRole = AccessibleRole.StaticText;
    //textBox2.AccessibleRole = AccessibleRole.StaticText;

    vk.KeyPressed += Vk_KeyPressed;

    SetReadOnly(textBox1, true);
    SetReadOnly(textBox2, true);

    textBox1.KeyPress += OnTextBoxKeyPress;
    textBox2.KeyPress += OnTextBoxKeyPress;
}


private void OnTextBoxKeyPress(object sender, KeyPressEventArgs e)
{
    var timer = new Timer();
    timer.Interval = 3;
    timer.Tick += (s, a) =>
    {
        SetReadOnly(textBox1, true);
        SetReadOnly(textBox2, true);
        timer.Stop();
    };
    timer.Start();
}

private void Vk_KeyPressed(object sender, MindFusion.UI.WinForms.VirtualKeyEventArgs e)
{
    SetReadOnly(textBox1, false);
    SetReadOnly(textBox2, false);
}
 



I have tested this only on desktop machine with touch screen and win10 tablet mode enabled. You should be able to extend it to support more edit boxes by following currently focused control rather than setting ReadOnly on specific boxes.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint