News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How can I set the qwerty keyboard as the current input method?

By Yaroslav Goncharov, November 09, 2001.
Print version

Question

My application needs to set qwerty keyboard as current input method. How can I do it?

Answer

You can use SipSetCurrentIM(CLSID *pClsid)method to set current input method. Now we need to find class id for qwerty keyboard. The following source code sets qwerty keyboard as current input method.

CLSID clsidQwertyIM = __uuidof(CMSQwertyIm); ::SipSetCurrentIM(&clsidQwertyIM);

However, this solution is not perfect. Lets imagine the situation when there is no qwerty keyboard in the system or modern keyboard replaces default one. MSDN says If the SIP is unable to load the IM, the default IM is loaded in its place. But in fact, system can have unpredictable behavior in this situation. For instance, Cassiopeia E-125 will deselect current IM and user will not see SIP panel in response on SIP button mouse click. The following method solves this problem.

#include <sip.h> // This method sets qwerty keyboard as current IM // RET: TRUE indicates success. FALSE indicates failure. BOOL SetQwertyAsCurrentIM() { CLSID clsidQwertyIM = __uuidof(CMSQwertyIm); CLSID clsidOldIM, clsidCurIM; ::SipGetCurrentIM(&clsidOldIM); ::SipSetCurrentIM(&clsidQwertyIM); ::SipGetCurrentIM(&clsidCurIM); // check if qwerty was set if (clsidQwertyIM != clsidCurIM) { // set the old IM to avoid unpredictable behavior ::SipSetCurrentIM(&clsidOldIM); return FALSE; } return TRUE; }

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House