Showing and Hiding the Soft Input Panel in C++ Applications for the Pocket PC

 

The Soft Input Panel (SIP) in your Pocket PC application allows users to select from a variety of built-in or third-party Input Methods (IMs). You can easily control the SIP to be at your user's disposal when they need it, but out of your user interface when they don't.

What You Need

Microsoft eMbedded Visual C++ development system.

Gotchas

The standard method of showing and hiding the SIP (SIPShowIM) exhibits some problems in MFC dialogs.

Languages Supported

English.

Showing and Hiding the Current Input Method

Controlling the SIP in a C++ application is simple. Because SIP activity can change the size of your user interface, it is important to have a user interface that is prepared to react to any size input panel, not only the standard SIP panels (such as the character recognizer, the keyboard, and transcriber) but also future IMs from Microsoft or third-party developers.

Figure 1: Character Recognizer, hidden and shown.

Figure 2: Keyboard, hidden and shown.

Figure 3: Transcriber, hidden and shown.

Two different methods are used to show and hide the current IM. I've found that the standard method (SIPShowIM) exhibits intermittent problems with changing the state of the input method in Microsoft Foundation Class (MFC) dialogs. Other than that, it seems to work fine.

To show/hide the IM using the standard SIPShowIM() function:

  1. #include the SIPAPI.H file in your application source.
  2. To show the current IM: Inside the event handler (such as the WM_INITDIALOG processing code for a dialog, or the WM_SETFOCUS processing code for a control), call SIPShowIM(SIPF_ON).
  3. Process the WM_SIZE event that comes to your user interface, or simply query the size of the window during the processing of WM_PAINT to adjust the interface to allow room for the IM.
  4. To hide the current IM: Inside the event handler that closes the corresponding dialog, or when a control loses focus if you want to track each control, call SipShowIM(SIPF_OFF). In general, you should set the IM state to whatever it was before you changed it; you can query the current state using the SipGetInfo() function covered in the next section.

Another method of showing and hiding the current IM, is to use the SHSipPreference() function. This function requires that you:

  1. Pass the HWND of the window in which you want the SIP to change as the first parameter.
  2. Pass either SIP_UP (to show the IM) or SIP_DOWN (to hide the IM) for the second parameter.

Querying the State of the SIP

Ideally, any time you change the state of a shared resource such as the SIP, you will want to return it to whatever state it was initially in when you are done with it. In order to do this, you need to query the state of the resource before you change it and save its state, and then have it revert to this state when your application or window is closed.

To query the current state of the SIP:

  1. #include the SIPAPI.H file in your application source.

  2. Call the SipGetInfo() function to obtain a SIPINFO structure.

  3. Check the fdwFlags member to see whether the SIP is turned on (SIPF_ON) or off (SIPF_OFF).

    Note that there is a typo in the online Help for Microsoft eMbedded Visual C++ that states that the off state is SIP_OFF, when it should be SIPF_OFF.

You have the option of using the full rectangle of the desktop if the SIP is turned off, or the remaining visible area if the SIP is turned on. The current visible area (not including the SIP) is available through the rcVisibleDesktop member. The rectangle of the SIP itself is shown in the rcSipRect member.

Conclusion

When properly used, the Pocket PC's soft input panel allows users to enjoy a great variety of input, and can be hidden when it isn't required, giving your application valuable extra screen real estate.