Tutorials to .com

Tutorials to .com » Os » Mobile » Win CE development in the use of the software input panel

Win CE development in the use of the software input panel

Print View , by: iSee ,Total views: 26 ,Word Count: 4923 ,Date: Sat, 13 Jun 2009 Time: 2:45 PM

Introduction

software Input Panel (Software Input Panel, referred to as SIP) is a WinCE system equipped with a mobile platform, the basic functions. It provides to the user on the PDA as a means of data entry. When one talks about SIP, we usually think of two things: First, SIP itself, the second is how to use in the procedure SIP.

SIP is a realization of the IInputMethod or IInputMethod2 the COM object interface. It should be transferred to the use of the system, so you can not be carried out in c # in the development of SIP. C++ or C + + is a very good development language. SIP itself as just another COM object, ATL makes the development process becomes extremely simple. I do not want to discuss here, SIP development, SDK bag contains a very good routine ATLDvoraksip, so you can go to learn this routine in order to obtain more information. I would like to discuss here is how to program your own management of SIP. It seemed very simple and trivial, but if not enough because of the screen, and you want to make your procedures more user-friendly smart, and that the management of SIP will become a very important aspect of the. In addition, if you develop a lot of different occasions for the SIP (such as multi-lingual, digital or other, etc.), you may want to use on one occasion when a particular SIP. This capability allows you to complete many different tasks: When a user is only required when the digital input, you can display a large number of the keyboard, so he does not need to use pens and fingers can be entered. Of course, you can also have their own ideas, which look at what the programmers had.

Win32 API

SIP-API function is very simple, from sipapi.h can only see only a very small number of functions:

DWORD WINAPI SipStatus();
BOOL WINAPI SipSetDefaultRect(RECT *);
BOOL WINAPI SipRegisterNotification(HWND);
BOOL WINAPI SipShowIM(DWORD);
BOOL WINAPI SipGetInfo(SIPINFO *);
BOOL WINAPI SipSetInfo(SIPINFO *);
int WINAPI SipEnumIM(IMENUMPROC);
BOOL WINAPI SipGetCurrentIM(CLSID *);
BOOL WINAPI SipSetCurrentIM(CLSID *);

I started them on because it supports both Windows Mobile and CE.NET platforms. If you are programming on Windows Mobile devices, then aygshell.h document and give you more a function of the SIP for use. Of course, choose to use depends on your own needs, and the use of SIP on Windows Mobile will make some more perfect. If you use the same os version, but different versions of the build, you may be slightly different behavior of the SIP. Therefore, a method does not necessarily think like you, as all will be applicable on the PDA.

SIP list available

The first step is to learn how to list all the available SIP. Can use the following code:

CTypedPtrMap<CMapStringToPtr,CString,CLSID*> g_SipMap;
int SipEnumIMProc(IMENUMINFO *pIMInfo)
{
CLSID* pCLSID = new CLSID;
memcpy(pCLSID,&pIMInfo->clsid,sizeof(CLSID));
g_SipMap.SetAt(CString(pIMInfo->szName),pCLSID);
TRACE(_T("%sn"),CString(pIMInfo->szName));
return 1;
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CString sSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
}
}
CTypedPtrMap<CMapStringToPtr,CString,CLSID*> g_SipMap;
int SipEnumIMProc(IMENUMINFO *pIMInfo)
{
CLSID* pCLSID = new CLSID;
memcpy(pCLSID,&pIMInfo->clsid,sizeof(CLSID));
g_SipMap.SetAt(CString(pIMInfo->szName),pCLSID);
TRACE(_T("%sn"),CString(pIMInfo->szName));
return 1;
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CString sSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
}
}
CTypedPtrMap<CMapStringToPtr,CString,CLSID*> g_SipMap;
int SipEnumIMProc(IMENUMINFO *pIMInfo)
{
CLSID* pCLSID = new CLSID;
memcpy(pCLSID,&pIMInfo->clsid,sizeof(CLSID));
g_SipMap.SetAt(CString(pIMInfo->szName),pCLSID);
TRACE(_T("%sn"),CString(pIMInfo->szName));
return 1;
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CString sSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
}
}
CTypedPtrMap<CMapStringToPtr,CString,CLSID*> g_SipMap;
int SipEnumIMProc(IMENUMINFO *pIMInfo)
{
CLSID* pCLSID = new CLSID;
memcpy(pCLSID,&pIMInfo->clsid,sizeof(CLSID));
g_SipMap.SetAt(CString(pIMInfo->szName),pCLSID);
TRACE(_T("%sn"),CString(pIMInfo->szName));
return 1;
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CString sSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
}
}
CTypedPtrMap<CMapStringToPtr,CString,CLSID*> g_SipMap;
int SipEnumIMProc(IMENUMINFO *pIMInfo)
{
CLSID* pCLSID = new CLSID;
memcpy(pCLSID,&pIMInfo->clsid,sizeof(CLSID));
g_SipMap.SetAt(CString(pIMInfo->szName),pCLSID);
TRACE(_T("%sn"),CString(pIMInfo->szName));
return 1;
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CString sSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
}
}

Code is made by filling an overall map, it contains "SIP name" / CLSID right. This example and others have used the MFC, of course, you can also use the familiar Win32 API or any other framework. The following is my Dell Axim x50 display results:

How to select, display and hide specific SIP

When you know a SIP-CLSID, you can select it. At the same time, the current choice of SIP can be obtained:

void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}
void CSIPDemoDlg::OnButtonEnum()
{
SipEnumIM(SipEnumIMProc);
CLSID CurrSip;
SipGetCurrentIM(&CurrSip);
int nCurrSip = LB_ERR, nSipCount = 0;
CString sSipName, sCurrSipName;
CLSID *pCLSID = NULL;
for (POSITION pos = g_SipMap.GetStartPosition(); pos; )
{
g_SipMap.GetNextAssoc(pos,sSipName,pCLSID);
m_SipList.AddString(sSipName);
if ( memcmp(&CurrSip,pCLSID,sizeof(CLSID)) == 0 )
{
nCurrSip = nSipCount;
sCurrSipName = sSipName;
}
nSipCount++;
}
m_SipList.SelectString(0,sCurrSipName);
}
void CSIPDemoDlg::OnButtonSelect()
{
int nSel = m_SipList.GetCurSel();
if ( LB_ERR == nSel )
return;
CString sSipName;
m_SipList.GetText(nSel,sSipName);
CLSID *pCLSID = NULL;
if ( !g_SipMap.Lookup(sSipName,pCLSID) )
return;
BOOL bRes = SipSetCurrentIM(pCLSID);
if ( !bRes )
TRACE(L"SipSetCurrentIM returned %lun",GetLastError());
}
void CSIPDemoDlg::OnButtonShowHide()
{
if ( !g_bShow )
{
SipShowIM(SIPF_ON);
g_bShow = TRUE;
}
else
{
SipShowIM(SIPF_OFF);
g_bShow = FALSE;
}
}
void CSIPDemoDlg::OnButtonShowHide2()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
if ( !g_bShow )
{
SipInfo.fdwFlags |= SIPF_ON;
g_bShow = TRUE;
}
else
{
SipInfo.fdwFlags = SIPF_OFF;
g_bShow = FALSE;
}
bRes = SipSetInfo(&SipInfo);
}
else
{
TRACE(L"SipGetInfo returned %lun",GetLastError());
}
}

Here, you can see examples of modifications (CSIPDemoDlg:: OnButtonEnum ()), it detects any SIP is activated in the listbox and select the corresponding line. Other examples of the method of choice of SIP dialog and show or hide it. Note that in order to make SipGetInfo or SipSetInfo work, you must be sizeof (SIPINFO) to initialize the value SIPINFO.cbSize, a normal reaction to this operating system. This is a very common solution Win32.

SipGetInfo to your desktop and SIP visual size, so that you can customize when necessary, re-location of SIP. SipSetInfo will not change the location of SIP. If you need to move SIP, the use of SipSetDefaultRect. The following will give some examples to illustrate the.

Use Shell function

If you decide to use a function aygshell based, SHSipPreference will be for you to complete similar tasks. And SipShowIM, this API will show and hide input panel. Finally, it defines a parameter for what, you can request to show or hide Input Panel as soon as the hidden (because the operating system in a conventional case where a timer will be set up for this purpose) or to give up all the waiting request. SHSipInfo allows you to make and operate the same SipXXX function.

Usually, you can use the API to all of the above WM_SETTINGCHAANGE or in response to WM_CREATE message. According to the document, when you use to deal with SHSipInfo news WM_SETTINGCHANGE to be especially careful. There are several reasons for this: First, SIP may lead to changes in shell to send WM_SETTINGCHANGE information, so when you deal with in your function call in time to be careful infinite loop; second, SHSipInfo will be as well as the input surface Device.exe board thread interaction, it will occupy a period of about 100ms. This will lead to WM_SETTINGCHANGE message sent to all running programs, so the system will be lost in response to a period of time. At the same time, and the lParam value to WM_SETTINGCHANGE to avoid such a transfer will be delayed.

When it comes to shell functions, some of the Windows Mobile platform will be very useful function may also allow you to become a headache. These include SHInputDialog, SHFullScreen or similar call. In addition, SHHandleWMActivate and SHHandleWMSettingChange will let you process the full enjoyment of MFC keyboard automatically pops up the fun, as they are used in the appropriate message handler class CDialog and CFrameWnd. If you do not want to have the default behavior, you can handle heavy-duty OnActivate or OnSettingChange.

Custom Control

If you want to support an intelligent input box kind of behavior - each automatic pop-up keyboard input, and then when the input focus away from the input box after the keyboard hidden, then the need to deal with WM_SETFOCUS and WM_KILLFOCUS. The following code can help you:

void CSipEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
SHSipPreference(m_hWnd,SIP_UP);
}
void CSipEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
SHSipPreference(m_hWnd,SIP_FORCEDOWN);
}
void CSipEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
SHSipPreference(m_hWnd,SIP_UP);
}
void CSipEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
SHSipPreference(m_hWnd,SIP_FORCEDOWN);
}
void CSipEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
SHSipPreference(m_hWnd,SIP_UP);
}
void CSipEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
SHSipPreference(m_hWnd,SIP_FORCEDOWN);
}
void CSipEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
SHSipPreference(m_hWnd,SIP_UP);
}
void CSipEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
SHSipPreference(m_hWnd,SIP_FORCEDOWN);
}
void CSipEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
SHSipPreference(m_hWnd,SIP_UP);
}
void CSipEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
SHSipPreference(m_hWnd,SIP_FORCEDOWN);
}

SIP settings location

SIP to talk about how to move the following to a location on the screen. SipSetDefaultRect to change the default SIP will be held, but it will not take effect immediately, unless you re-select the input method:

void CSIPDemoDlg::OnButtonMove()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
CRect rc(SipInfo.rcSipRect);
rc.OffsetRect(0,-20);
SipSetDefaultRect(&rc);
CLSID clsid;
if ( SipGetCurrentIM(&clsid) )
{
SipSetCurrentIM(&clsid);
}
SipShowIM(SIPF_ON);
}
}
void CSIPDemoDlg::OnButtonMove()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
CRect rc(SipInfo.rcSipRect);
rc.OffsetRect(0,-20);
SipSetDefaultRect(&rc);
CLSID clsid;
if ( SipGetCurrentIM(&clsid) )
{
SipSetCurrentIM(&clsid);
}
SipShowIM(SIPF_ON);
}
}
void CSIPDemoDlg::OnButtonMove()
{
SIPINFO SipInfo;
memset(&SipInfo,0,sizeof(SipInfo));
SipInfo.cbSize=sizeof(SIPINFO);
BOOL bRes = SipGetInfo(&SipInfo);
if ( bRes )
{
CRect rc(SipInfo.rcSipRect);
rc.OffsetRect(0,-20);
SipSetDefaultRect(&rc);
CLSID clsid;
if ( SipGetCurrentIM(&clsid) )
{
SipSetCurrentIM(&clsid);
}
SipShowIM(SIPF_ON);
}
}

Code above the screen to tell you how to move the location of SIP. This low-end you want on the screen to put in the time control will be very useful. Of course, this does not comply with Microsoft's Pocket PC's GUI design standards, but sometimes you have no other choice.

If you can get the window handle to control the style of window, such as:

long lStyle=GetWindowLong(hwndSIP,GWL_STYLE);
lStyle |= WS_CAPTION|WS_SYSMENU;
SetWindowLong(hwndSIP,GWL_STYLE,lStyle);

Concluding remarks

We have already discussed the WindowsCE operating system in the management of a number of SIP, the hope that these procedures can help you become a winner in the eyes of users.


Mobile OS Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.