Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I want always inactive my windows application form. like on screen keyboard
How can i do it
Posted
Updated 5-Jul-12 7:14am
v2
Comments
[no name] 5-Jul-12 12:59pm    
Please improve your question. This does not make any sense.
Sergey Alexandrovich Kryukov 5-Jul-12 13:23pm    
I think I know what is it. This is a tricky situation, but I found the solution long time ago. Please see my answer.
--SA

The question is very unclear, but I think I can guess what's the problem. Indeed, with a virtual keyboard, when you click on a key, you need some target application to be active, so the simulated keyboard input would be dispatched to this application; at the same time, to be able to click a key on a virtual keyboard, you need to have it on top.

Therefore, we have some seemingly contradictory requirements for the virtual keyboard window; and this problem can be resolved by giving it pretty unusual combination of window parameters: it should be "always on top" and "no activate" at the same time. This is quite possible through overriding the virtual method System.Windows.Forms.Form.CreateParams:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.createparams.aspx[^].

I've shown a complete solution in my past answer:
Application focus getting and losing[^].

Please also see:
Creating a Virtual Keyboard[^].

—SA
 
Share this answer
 
Comments
Abhinav S 5-Jul-12 13:42pm    
Based on the OP's question, this is the best guess answer. 5.
Sergey Alexandrovich Kryukov 5-Jul-12 14:48pm    
Thank you, Abhinav.
--SA
Sergey Alexandrovich Kryukov 11-Jul-12 15:29pm    
...and I'm pleased to confirm that your trust to my guess was justified -- OP confirmed that it resolved the problem.
Thank you again.
--SA
Espen Harlinn 5-Jul-12 14:10pm    
Nothing further to add :-D
Sergey Alexandrovich Kryukov 5-Jul-12 14:48pm    
Thank you, Espen.
--SA
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace testt


{

    public partial class Form1 : Form
    {
        internal const int WS_EX_TOPMOST = 8;
        internal const int WS_EX_NOACTIVATE = 0x08000000;

        public Form1()
        {
            InitializeComponent();
        }
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams par = base.CreateParams;
                if (DesignMode) return par;
                par.ExStyle |= WS_EX_TOPMOST;
                par.ExStyle |= WS_EX_NOACTIVATE;
                return par;
            } //get CreateParams
        } //

        private void Form1_Load(object sender, EventArgs e)
        {

        }



    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900