Click here to Skip to main content
Click here to Skip to main content

Onscreen Keyboard

By , 21 Mar 2000
 
  • Download source files - 143 Kb

    Sample Image - OnscreenKeyboard.gif

    I needed a simple onscreen keyboard to interface with a touch / pen based computer that I bought through an online auction. Although Microsoft supplies one with its Pen Extensions 2.0 it only works win Win95 and I wanted to use NT.

    All of the available onscreen keyboards I found were either too expensive, or they were only designed to operate with 3.1 and 9x so (of course) I decided to see if I could make one. Along the way I learned a little about how the keyboard is handled, and the thread keyboard maps.

    Included with this article is a working, but simple, onscreen keyboard. I submitted it mostly as an example of the methods:

    • AttachThreadInput
    • keybd_event
    • VkKeyScan
    • GetKeyState

    This program has one nasty limitation, and that is that it "flashes" since it does not prevent the changing of focus to itself when clicked, and then back to the target window when the keystroke is generated. If someone wants to tackle that one please feel free ;-)

  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Randy More
    United States United States
    Member
    No Biography provided

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    QuestionI have a problem with the address barmemberarrodenas4 Nov '06 - 10:35 
    Hello. i´m from Spain so i´m sorry for my english.
     
    I have the same problem with the focus. I´m doing an onscreenkeyboard and i can´t send characters to the address bar, because after i send a character, the next it´s overwrite.
     
    I think that the problem maybe is the focus. Anyone knows one possibility to never have the focus or another solution.
     
    Thank you very much.Smile | :)
    AnswerRe: I have a problem with the address bar Pinmemberstorein19 Dec '06 - 23:57 
    Dirk Moshage's method can resolve your issue.
     
    Hello, I've solved the focus problem. The solution is to catch the WM_MOUSEACTIVATE message and return MA_NOACTIVATE.
     
    Changes in OnscreenKeyboardDlg.cpp:
     
    BEGIN_MESSAGE_MAP(COnscreenKeyboardDlg, CDialog)
    ...
    ON_WM_MOUSEACTIVATE()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
     
    int COnscreenKeyboardDlg::OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message )
    {
    return MA_NOACTIVATE;
    }
     

    Changes in OnscreenKeyboardDlg.h:
     
    //{{AFX_MSG(COnscreenKeyboardDlg)
    ...
    afx_msg int OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message );
    ...
    //}}AFX_MSG
     
    That's all.
     

    GeneralRe: I have a problem with the address bar Pinmemberarrodenas2 Jan '07 - 8:33 
    Thank you very much, but the problem already has been solved otherwise. Initially, I tried your method, but it was not solving the problem.
     

    After many investigations, I fell down in the account that it was necessary to define a style of window of Windows.
     
    Anyhow thank you for answering to my question.Smile | :)

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Permalink | Advertise | Privacy | Mobile
    Web02 | 2.6.130516.1 | Last Updated 22 Mar 2000
    Article Copyright 2000 by Randy More
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid