Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Manage Windows XP On Screen Keyboard

0.00/5 (No votes)
22 Apr 2009 1  
Windows XP offers an On Screen Keyboard, but sometimes requires a little customization

Introduction

I was developing an application to be used on a panel PC and I faced the customer request to use only the touchscreen to enter any data required by my application. My first idea was to design by hand a form with as many buttons as a regular keyboard, but I changed my mind immediately. Next, after some web searching, I decided to use the standard on screen keyboard provided by Windows XP. 

Background

When you start the on screen keyboard (OSK.EXE) the first thing you can observe is that it is too small to be used with the resolution of a modern monitor, but the OSK doesn't allow you to resize it. This problem can be easily solved using the SetWindowPos API in order to set the requested size and position. The screen keyboard is presented as a usual application, so it has a window frame with control boxes and a menu. The control box could cause the keyboard application to close if the user clicks on the cross button (window close), and the menu is useless for the normal data entry. Nonetheless, the window frame and the menu consumes screen area. But how to remove these elements? The SetWindowLong API does the job. 

Using the Code

The class exposes three shared methods: 

'Shows the keyboard creating the process if necessary 
 ClKeyboard.Show()

'Hides the keyboard without killing the process  
 ClKeyboard.Hide()

'Kill the process that manages the keyboard 
ClKeyboard.Kill()  

When you call Show, the keyboard appears at the bottom of the screen, just above the taskbar, and is 350px tall while its width matches the screen width. These parameters are hard coded in the class, but they can be easily changed. 

Hope you enjoy this class. 

History

  • 22nd April, 2009: Initial post

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