virtual key board as a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nayanar
    New Member
    • Feb 2010
    • 11

    virtual key board as a form

    Hello i am new to c#
    please help me for the following problem

    Que:

    i have one form application with few buttons say app1 on it
    and two another form application with textbox in it say app2 and app3
    now i need to type in app2's or app3 's textbox using those buttons on app1
    how can i know which is active among app2 and app3.
    and how can i tell app1 abt which text box is in focus in the active application

    thanks in advance
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Originally posted by OriginalPoster
    How do I get my Form2 to react to something on my Form1?
    How do I make my Form1 control something on my Form2?
    Although you can have Form1 directly access items on Form2 it isn't the recommended way to go. It ties the two forms tightly to each other. If a change is made in Form2 such as removing one of the controls, then code in Form1 breaks.
    It is better to Form1 raise an event, and have Form2 contain its own code for how to react to this. This places responsibility for Form2 within Form2, and Form1 within Form1.
    It keeps Form1 blissfully ignorant of Form2 - and a logging component - and a progress component, and a dozen other little black boxes that can be subscribed to events in Form1, all without Form1 being made responsible for directly affecting controls other than itself.
    Events tutorial (including Form to Form which is the same as class to class)

    Your question title indicates you are trying to make a virtual keyboard. This tutorial for a cash register does exactly that: It makes a virtual numeric keyboard. The only difference is that you will need another 100 keys.

    Comment

    • nayanar
      New Member
      • Feb 2010
      • 11

      #3
      my problem is like this

      i have two different application like on-screen keyboard and excel sheet

      in my problem i have:
      1st application: form with number buttons.
      2nd application: few forms with many texboxes in each.

      now i need to fill those text boxes with number using 1st application

      i want to how will 1st application know which text box of which form is having cursor and how will it send the data to it. i think it require knowledge of win32 api calls and all. which i very little idea. can u help me out in this .

      thanks in advance

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Are the two programs ones you have written?
        If so, you can code in some methods for the two to communicate with each other.

        Comment

        • nayanar
          New Member
          • Feb 2010
          • 11

          #5
          no they are two different applications... .just like a notepad and one screen keyboard. different solution itself.

          Comment

          • vishal1082
            New Member
            • Apr 2009
            • 92

            #6
            he meant if you wrote the code of both of the applications?

            Comment

            • nayanar
              New Member
              • Feb 2010
              • 11

              #7
              yes i have written the code. But i need to know how to find which application is active and how to send value to the it

              Comment

              • nayanar
                New Member
                • Feb 2010
                • 11

                #8
                here is code of application where i have to write

                Code:
                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;
                using System.Runtime.InteropServices;
                
                namespace simple_wind_fow
                {
                    public partial class simpleform3 : Form
                    {
                        public simpleform3()
                        {
                            InitializeComponent();
                        }
                        private void textBox1_Enter_1(object sender, EventArgs e)
                        {
                      
                          
                        }
                        private void textBox2_Enter(object sender, EventArgs e)
                        {
                           
                        }
                
                        private void simpleform3_Click(object sender, EventArgs e)//when clicked on that window
                        {
                            textBox1.Focus();
                        }
                
                         
                    }
                }
                Last edited by tlhintoq; Feb 25 '10, 02:00 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]

                Comment

                • nayanar
                  New Member
                  • Feb 2010
                  • 11

                  #9
                  this is the second application where is need to find active application and send value to it , when ever button is pressed

                  Code:
                  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;
                  using System.Runtime.InteropServices;
                  
                  namespace button
                  {
                      public partial class keyboard : Form
                      {
                          public keyboard()
                          {
                              InitializeComponent();
                          }       
                                        
                          private void button1_Click(object sender, EventArgs e)
                          {
                             //find the active application
                              //send value "1" to that application
                          }
                          private void button2_Click(object sender, EventArgs e)
                          {
                              //find the active application
                              //send value "2" to that application
                          }
                                
                      }
                   }
                  Last edited by tlhintoq; Feb 25 '10, 02:00 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]

                  Comment

                  • nayanar
                    New Member
                    • Feb 2010
                    • 11

                    #10
                    they are two different application which are two different exe file

                    Comment

                    • nayanar
                      New Member
                      • Feb 2010
                      • 11

                      #11
                      please do help. Its kind of urgent requirement

                      Comment

                      • vishal1082
                        New Member
                        • Apr 2009
                        • 92

                        #12
                        SendKeys.Send(K eys.Enter.ToStr ing()); will send the "Enter" key for example to the currently Active form., though i dont understand how will you manage to keep focus on your main form instead of your keyboard form when someone *clicks* a button for a keypress on the keyboard form since both are in different exe.

                        Comment

                        • tlhintoq
                          Recognized Expert Specialist
                          • Mar 2008
                          • 3532

                          #13
                          TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

                          Comment

                          • tlhintoq
                            Recognized Expert Specialist
                            • Mar 2008
                            • 3532

                            #14
                            With what you have coded thus far you can forget about this working for you.
                            And I use the term 'coded' very loosely. You have about 10 seconds of work here.

                            Vishal is right that program one looses focus as soon as you click a button on program 2. You are going to have to do some work to keep track of which field was last clicked in. Then when that application receives a message, put the the message (key click/button click) into the proper field.

                            Comment

                            • nayanar
                              New Member
                              • Feb 2010
                              • 11

                              #15
                              ok.
                              for example if i have calculator ,notepad and a inbuilt on-screen keyboard opened on my desktop sequentially in the same order. and if i type using onscreen keyboard , how will this on screen keyboard is getting to know that it has to type in notepad. how does that work. can i use the same logic which the onscreen keyboard is using. Do u ppl know how does that on screen keyboard do it. Please help

                              Comment

                              Working...