on screen keyboard

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jonathandrott@gmail.com

    #1

    on screen keyboard

    Hi, i'm kinda new to vb.net and i'm trying to make an on screen
    keyboard to use with a touch screen. how do i get it to print a
    letter on the screen when the button is pressed in the textbox that is
    selected? do i do it as a ascii character?

    i'm trying to get data from a user. there are a couple of different
    field the user will have to type information into. (i.e. first name,
    last name, .etc)

  • rowe_newsgroups

    #2
    Re: on screen keyboard

    On Mar 29, 11:41 am, jonathandr...@g mail.com wrote:
    Hi, i'm kinda new to vb.net and i'm trying to make an on screen
    keyboard to use with a touch screen. how do i get it to print a
    letter on the screen when the button is pressed in the textbox that is
    selected? do i do it as a ascii character?
    >
    i'm trying to get data from a user. there are a couple of different
    field the user will have to type information into. (i.e. first name,
    last name, .etc)
    Are you trying to write a global on screen keyboard or just one to use
    in your application only?

    Thanks,

    Seth Rowe

    Comment

    • Martin H.

      #3
      Re: on screen keyboard

      Hello Jonathan,

      the easiest thing would be to raise an event which contains a variable
      with the keycode or the string. However, when developing such a keyboard
      (I once wrote one as an OCX, which can be downloaded from
      www.henke-hk.com), please keep in mind that there are different layouts
      (e.g. on German keyboards you have to press AltGr (Ctrl+Alt)+Q to get
      the "@" sign). Considering that .NET supports Unicode, you might need to
      consider Chinese/Japanese keyboards and their input methods as well.

      Best regards,

      Martin

      jonathandrott@g mail.com wrote:
      Hi, i'm kinda new to vb.net and i'm trying to make an on screen
      keyboard to use with a touch screen. how do i get it to print a
      letter on the screen when the button is pressed in the textbox that is
      selected? do i do it as a ascii character?
      >
      i'm trying to get data from a user. there are a couple of different
      field the user will have to type information into. (i.e. first name,
      last name, .etc)
      >

      Comment

      • jonathandrott@gmail.com

        #4
        Re: on screen keyboard

        On Mar 29, 12:03 pm, "rowe_newsgroup s" <rowe_em...@yah oo.comwrote:
        On Mar 29, 11:41 am, jonathandr...@g mail.com wrote:
        >
        Hi, i'm kinda new to vb.net and i'm trying to make an on screen
        keyboard to use with a touch screen. how do i get it to print a
        letter on the screen when the button is pressed in the textbox that is
        selected? do i do it as a ascii character?
        >
        i'm trying to get data from a user. there are a couple of different
        field the user will have to type information into. (i.e. first name,
        last name, .etc)
        >
        Are you trying to write a global on screen keyboard or just one to use
        in your application only?
        >
        Thanks,
        >
        Seth Rowe
        it's with my application

        Comment

        • rowe_newsgroups

          #5
          Re: on screen keyboard

          On Mar 30, 7:24 pm, jonathandr...@g mail.com wrote:
          On Mar 29, 12:03 pm, "rowe_newsgroup s" <rowe_em...@yah oo.comwrote:
          >
          >
          >
          On Mar 29, 11:41 am, jonathandr...@g mail.com wrote:
          >
          Hi, i'm kinda new to vb.net and i'm trying to make an on screen
          keyboard to use with a touch screen. how do i get it to print a
          letter on the screen when the button is pressed in the textbox that is
          selected? do i do it as a ascii character?
          >
          i'm trying to get data from a user. there are a couple of different
          field the user will have to type information into. (i.e. first name,
          last name, .etc)
          >
          Are you trying to write a global on screen keyboard or just one to use
          in your application only?
          >
          Thanks,
          >
          Seth Rowe
          >
          it's with my application
          Then the absolute easiest way would be to create a usercontrol that
          will act as the keyboard. Then you just have worry about passing the
          pressed key back to the "target" control.

          Here's a quick sample I just wrote:

          First comes the user control. For it you need to add some labels, one
          for each key of the keyboard. I set the label's Textalign to
          MiddleCenter and the BorderStyle to single to give it more of a key-
          like look, though if this was a profession app, I would do some GDI+
          work to make the label look more like a button. The reason you need to
          use a label and not a button is that labels don't receive focus when
          clicked.

          Next, add the following code the user control. Note I changed the
          inherits to Panel to prevent the usercontrol from getting focus, so
          you'll have to change the inherits in the usercontrol.Des igner.vb file
          too.

          Public Class Keyboard
          Inherits Panel

          ' Wire up all the Label's click events to this event handler
          Private Sub Label_Click(ByV al sender As System.Object, ByVal e As
          System.EventArg s)
          OnKeyPressed(Ne w KeyPressedEvent Args(DirectCast (sender,
          Label).Text))
          End Sub

          Public Event KeyPressed As KeyPressedEvent Handler

          Protected Overridable Sub OnKeyPressed(By Val e As
          KeyPressedEvent Args)
          RaiseEvent KeyPressed(Me, e)
          End Sub

          End Class

          Public Delegate Sub KeyPressedEvent Handler(ByVal sender As Object,
          ByVal e As KeyPressedEvent Args)

          Public Class KeyPressedEvent Args
          Inherits EventArgs

          Public Sub New(ByVal keyPressed As String)
          Me.KeyPressed = keyPressed
          End Sub

          Private _KeyPressed As String
          Public Property KeyPressed() As String
          Get
          Return _KeyPressed
          End Get
          Private Set(ByVal value As String)
          _KeyPressed = value
          End Set
          End Property

          End Class

          That should be it for the usercontrol, now we just have to worry about
          the "host" form. All you have to do is add the new keyboard
          usercontrol to a form and then handle the usercontrol's new KeyPressed
          event. Use something like the following:

          Private Sub Keyboard1_KeyPr essed(ByVal sender As System.Object,
          ByVal e As KeyPressedEvent Args)
          ' You'll have to change this cast if you want to send text
          ' to a control type other than a TextBox
          Dim tb As TextBox = TryCast(Me.Acti veControl, TextBox)
          If Not tb Is Nothing Then
          tb.Text &= e.KeyPressed
          tb.SelectionSta rt = tb.Text.Length
          End If
          End Sub

          Since neither the usercontrol or it's labels can get the focus, the
          event handler will try to cast the active control (the control that
          had focus before the user clicked the keyboard usercontrol) into a
          textbox and then append the text from the KeyPressed event.

          I'm guessing there is a more elegant solution to this, but at this
          late at night I can't think of one :-) Anyways, I hope it helps you
          out!

          Thanks,

          Seth Rowe

          Comment

          Working...