Results 1 to 7 of 7

Thread: keyboard buffer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    74

    Question

    I want to produce an on-screen keyboard as a component
    that could be used from the toolbox.

    When user presses a key the corresponding character should
    be inserted in the control that have focus - without
    affecting focus.

    Question is:
    How could I put chars in the keyboad buffer just as if they where inserted from keyboard and without affecting which control having focus?

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, here is an example:

    Code:
    Private Sub cmdA_click ()
    SendKeys "{A}"
    End sub
    is that what you need?
    NXSupport - Your one-stop source for computer help

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    74
    Ok-that takes care of the text input, but unfortunately
    it takes the focus of the subject that should have the text.

  4. #4
    Guest
    Actually, Sendkeys can be used to type in regular text.

    Code:
    SendKeys "Text is going wherever the focus is"
    That what you wanted?

  5. #5
    Guest
    I think he means that the former control loses its focus, then he doesn't know which one to send the keys to. If this is the case, then just store the control that lost the focus in a variable.

    Put the following in a Form with 3 TextBoxes and a CommandButton.
    Code:
    'Store the last control in a variable
    Dim LastControl As Control
    
    Private Sub Command1_Click()
        LastControl.SetFocus    'Give the focus to the lastcontrol
        SendKeys "A"
    End Sub
    
    Private Sub Text1_LostFocus()
        Set LastControl = Text1
    End Sub
    
    Private Sub Text2_LostFocus()
        Set LastControl = Text2
    End Sub
    
    Private Sub Text3_LostFocus()
        Set LastControl = Text3
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    74
    Well I guess that it is a way to do it.

    But what I really wanted was that the keyboard component should keep track of which object that has lost the focus and who to give it back to after a "virtual key" is pressed
    So there should be a minimum of extra code to implement the virtual keyboard.

    Thanks anyway.

  7. #7
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    megatron's way is the only way i can think of, unless you incorporate a timer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width