I'm wrinting a program that is Japanese on screen keyboard. When I use the ImmSetOpenStatu s function to open IME for the focus windows as MS words... But it have been always failed. This is my code:
I dont know where is wrong. please help me.
Code:
BOOL COnscreenKeyboardDlg::SetImeSwitchON()
{
m_fLog.initLogFile();
HWND wnd = ::GetForegroundWindow();
if(IsWindow(wnd))
{
if(!AttachThreadInput(GetWindowThreadProcessId(m_hWnd,NULL),GetWindowThreadProcessId(wnd,NULL),TRUE)){
m_fLog.putToLogFile( __FILE__, __LINE__, "AttachThreadInput failed\n");
}
::SetFocus(wnd);
char cWindowsName[MAX_PATH];
::GetWindowText(wnd,cWindowsName,MAX_PATH);
m_fLog.putToLogFile( __FILE__, __LINE__, cWindowsName);
HIMC hIMC = ImmGetContext(wnd);
if(!ImmGetOpenStatus(hIMC)){
if(!ImmSetOpenStatus(hIMC, TRUE)){
m_fLog.putToLogFile( __FILE__, __LINE__, "ImmSetOpenStatus failed\n");
}else{
m_fLog.putToLogFile( __FILE__, __LINE__, "ImmSetOpenStatus successed\n");
}
}
ImmReleaseContext( wnd, hIMC);
}else{
m_fLog.putToLogFile( __FILE__, __LINE__, "IsWindow(wnd) failed\n");
}
m_fLog.closeLogFile();
return 0;
}
Comment