Programming Input Methods

An IM is an in-process Component Object Model (COM) server that implements the IInputMethod interface. Windows CE provides a default QWERTY keyboard IM to handle alpha-numeric input. The IM manages the space inside the input panel window. Within this window, the IM is responsible for screen output and responding to user input. Typically, an IM creates a child window of the input panel window. This enables the IM window to respond to user input through the input panel window; the IM does not have access to the input panel window's WindowProc function unless the IM subclasses that window. The IM usually converts user input into characters and sends those characters to the input panel through the IMCallback interface.

In order to use an IM, the user first selects the IM from the input panel dialog box or Input Panel button. The input panel dynamically loads the selected IM by calling the CoCreateInstance function. When the user selects a different IM, the input panel frees the existing IM by calling Release on the interface pointer. The input panel then calls IInputMethod methods to notify the IM of events and to request data. The input panel implements and exposes the IIMCallback interface. This interface lets the IM call the input panel to send keystrokes to the application through GWES. The following table shows the methods available through the IIMCallback interface.

IIMCallback method
Description
SetImInfo Lets the IM change the input panel icon and the visible state of the input panel
SendVirtualKey Modifies the global key state
SendCharEvents Sends Unicode characters to the window with the current focus
SendString Sends strings to the window with the current focus

In response to the input panel calls to IInputMethod, an IM creates windows in the contexts of the input panel thread. This way the input panel and the IM belong to the same message loop. For simplicity, all calls to IIMCallback should be made in the input panel thread. That is, the IM should call IIMCallback methods only in response to a call coming through an IInputMethod method.

Additionally, the IM should not create a separate thread to implement a UI. Only the thread that responds to IInputMethod methods should create and manipulate windows. Instead, the IM can create process threads to implement a UI. However, these process threads must not call IIMCallback, because certain GWES window functions work properly only if created from the same thread that created the window.

If you develop your own IM component, you should have your setup application perform self-registration by calling the DllRegisterServer and DllUnregisterServer functions. Implement these functions in the IM server dynamic-link library (DLL). Optionally, you can set the registry values directly. The Input Panel properties dialog box does not provide any UI elements for the self-registration service.