//取得输入法
DWORD dwSize;
DWORD dwi;
HKL hKL=0;
HKL *lphkl;
CString Buff;
dwSize=GetKeyboardLayoutList(0,NULL);
lphkl=(HKL*)GlobalAlloc(GPTR,dwSize*sizeof(DWORD));
if(!lphkl)
return NULL;
GetKeyboardLayoutList(dwSize,lphkl);
for(dwi=0;dwi<dwSize;dwi++)
{
char szFile[32];
HKL hKLTemp=*(lphkl+dwi);
ImmGetIMEFileName(hKLTemp,szFile,sizeof(szFile));//获得输入法的ime文件
if(ImmIsIME(*(lphkl+dwi))==1)//是中文输入法
{
int RCount=ImmGetDescription(*(lphkl+dwi),(LPTSTR)(LPCTSTR)Buff,255);//取得所有输入法
}
}
GlobalFree((HANDLE)lphkl);
==========================================================================================
开发输入法程序
输入法程序(IME)其实就是一种动态链接库(DLL),在动态链接库中导出下列函数:
BOOL WINAPI ImeInquire(LPIMEINFO lpIMEInfo,LPTSTR lpszUIClass,LPCTSTR lpszOption)return TRUE
BOOL WINAPI ImeConfigure(HKL hKL,HWND hWnd, DWORD dwMode, LPVOID lpData)return TRUE
DWORD WINAPI ImeConversionList(HIMC hIMC,LPCTSTR lpSource,LPCANDIDATELIST lpCandList,DWORD dwBufLen,UINT uFlag)return 0
BOOL WINAPI ImeDestroy(UINT uForce)return TRUE
LRESULT WINAPI ImeEscape(HIMC hIMC,UINT uSubFunc,LPVOID lpData)return TRUE
BOOL WINAPI ImeProcessKey(HIMC hIMC,UINT vKey,LPARAM lKeyData,CONST LPBYTE lpbKeyState)return TRUE
BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)return TRUE
BOOL WINAPI ImeSetActiveContext(HIMC hIMC,BOOL fFlag)return TRUE
UINT WINAPI ImeToAsciiEx (UINT uVKey,UINT uScanCode,CONST LPBYTE lpbKeyState,LPDWORD lpdwTransKey,UINT fuState,HIMC hIMC)return r
BOOL WINAPI NotifyIME(HIMC hIMC,DWORD dwAction,DWORD dwIndex,DWORD dwValue)return TRUE
BOOL WINAPI ImeRegisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)return TRUE
BOOL WINAPI ImeUnregisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)return TRUE
UINT WINAPI ImeGetRegisterWordStyle(UINT nItem, LPSTYLEBUF lp)return 0
UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROC lpfn, LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr, LPVOID lpData)return 0
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwComp, LPCVOID lpRead, DWORD dwRead)return FALSE
LRESULT WINAPI UIWndProc(HWND,UINT,WPARAM,LPARAM)return 0
示例D:/My Documents/Visual Studio Projects/freepy
==========================================================================================
.DEF文件为 链接器-输入-模块定义文件
.lib 链接器-高级-导入库
.tlb MIDL-输出-类型库
==========================================================================================
字体窗体
CClientDC dc(this);
HDC hDC;
CFont mFont;
hDC = ::GetDC(this->m_hWnd);
//创建字体
VERIFY(mFont.CreateFont(
200, 50, 0, 0, FW_HEAVY, TRUE, FALSE,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "宋体"));
if (hDC!=NULL)
{
//开始记录窗体轮廓路径
dc.BeginPath();
//设置背景为透明模式,这句话是必须有的。
dc.SetBkMode(TRANSPARENT);
CFont * pOldFont;
pOldFont = dc.SelectObject( &mFont );
dc.TextOut(0, 0, "VCKbase");
dc.SelectObject( pOldFont );
mFont.DeleteObject();
//结束记录窗体轮廓路径
dc.EndPath();
//把所记录的路径转化为窗体轮廓句柄
HRGN m_wndRgn = ::PathToRegion(dc);
//赋予窗体指定的轮廓形状
this->SetWindowRgn(m_wndRgn, TRUE);
}
DWORD dwSize;
DWORD dwi;
HKL hKL=0;
HKL *lphkl;
CString Buff;
dwSize=GetKeyboardLayoutList(0,NULL);
lphkl=(HKL*)GlobalAlloc(GPTR,dwSize*sizeof(DWORD));
if(!lphkl)
return NULL;
GetKeyboardLayoutList(dwSize,lphkl);
for(dwi=0;dwi<dwSize;dwi++)
{
char szFile[32];
HKL hKLTemp=*(lphkl+dwi);
ImmGetIMEFileName(hKLTemp,szFile,sizeof(szFile));//获得输入法的ime文件
if(ImmIsIME(*(lphkl+dwi))==1)//是中文输入法
{
int RCount=ImmGetDescription(*(lphkl+dwi),(LPTSTR)(LPCTSTR)Buff,255);//取得所有输入法
}
}
GlobalFree((HANDLE)lphkl);
==========================================================================================
开发输入法程序
输入法程序(IME)其实就是一种动态链接库(DLL),在动态链接库中导出下列函数:
BOOL WINAPI ImeInquire(LPIMEINFO lpIMEInfo,LPTSTR lpszUIClass,LPCTSTR lpszOption)return TRUE
BOOL WINAPI ImeConfigure(HKL hKL,HWND hWnd, DWORD dwMode, LPVOID lpData)return TRUE
DWORD WINAPI ImeConversionList(HIMC hIMC,LPCTSTR lpSource,LPCANDIDATELIST lpCandList,DWORD dwBufLen,UINT uFlag)return 0
BOOL WINAPI ImeDestroy(UINT uForce)return TRUE
LRESULT WINAPI ImeEscape(HIMC hIMC,UINT uSubFunc,LPVOID lpData)return TRUE
BOOL WINAPI ImeProcessKey(HIMC hIMC,UINT vKey,LPARAM lKeyData,CONST LPBYTE lpbKeyState)return TRUE
BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)return TRUE
BOOL WINAPI ImeSetActiveContext(HIMC hIMC,BOOL fFlag)return TRUE
UINT WINAPI ImeToAsciiEx (UINT uVKey,UINT uScanCode,CONST LPBYTE lpbKeyState,LPDWORD lpdwTransKey,UINT fuState,HIMC hIMC)return r
BOOL WINAPI NotifyIME(HIMC hIMC,DWORD dwAction,DWORD dwIndex,DWORD dwValue)return TRUE
BOOL WINAPI ImeRegisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)return TRUE
BOOL WINAPI ImeUnregisterWord(LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr)return TRUE
UINT WINAPI ImeGetRegisterWordStyle(UINT nItem, LPSTYLEBUF lp)return 0
UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROC lpfn, LPCTSTR lpRead, DWORD dw, LPCTSTR lpStr, LPVOID lpData)return 0
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwComp, LPCVOID lpRead, DWORD dwRead)return FALSE
LRESULT WINAPI UIWndProc(HWND,UINT,WPARAM,LPARAM)return 0
示例D:/My Documents/Visual Studio Projects/freepy
==========================================================================================
.DEF文件为 链接器-输入-模块定义文件
.lib 链接器-高级-导入库
.tlb MIDL-输出-类型库
==========================================================================================
字体窗体
CClientDC dc(this);
HDC hDC;
CFont mFont;
hDC = ::GetDC(this->m_hWnd);
//创建字体
VERIFY(mFont.CreateFont(
200, 50, 0, 0, FW_HEAVY, TRUE, FALSE,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "宋体"));
if (hDC!=NULL)
{
//开始记录窗体轮廓路径
dc.BeginPath();
//设置背景为透明模式,这句话是必须有的。
dc.SetBkMode(TRANSPARENT);
CFont * pOldFont;
pOldFont = dc.SelectObject( &mFont );
dc.TextOut(0, 0, "VCKbase");
dc.SelectObject( pOldFont );
mFont.DeleteObject();
//结束记录窗体轮廓路径
dc.EndPath();
//把所记录的路径转化为窗体轮廓句柄
HRGN m_wndRgn = ::PathToRegion(dc);
//赋予窗体指定的轮廓形状
this->SetWindowRgn(m_wndRgn, TRUE);
}