1. GetForegroundWindow return window handle to 0, and cannot obtain,
Exactly how to get focus window,
DWORD dwThread=GetWindowThreadProcessId (GetForegroundWindow (), NULL);
AttachThreadInput (dwThread, GetCurrentThreadId (), TRUE);
HWND hFocus=GetFocus ();
STD: : cout & lt;AttachThreadInput (dwThread, GetCurrentThreadId (), FALSE);
- to change the focus window input method,
Void SetImeConversionStatus (HWND& HWND, _IME_Mode mode)
{
HIMC HIMC=ImmGetContext (HWND);
If (mode==_IME_Off)
{
//the IME オ フ
ImmSetOpenStatus (hImc, FALSE);
}
The else
{
ImmSetOpenStatus (hImc, TRUE);
DWORD dwConversion=0;
DWORD dwSentence=0;
ImmGetConversionStatus (hImc, & amp; DwConversion, & amp; DwSentence);
STD: : cout & lt;The switch (mode)
{
Case _IME_Hiragana://ひ ら が な
DwConversion |=IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE;
DwConversion & amp;=~ IME_CMODE_KATAKANA;
break;
Case _IME_Katakana://Angle カ タ カ ナ
DwConversion |=
IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA;
break;
Case _IME_Alpha://the Angle of the number of
DwConversion |=IME_CMODE_FULLSHAPE;
DwConversion & amp;=~ (IME_CMODE_NATIVE | IME_CMODE_KATAKANA);
break;
Case _IME_KatakanaHalf://half Angle カ タ カ ナ
DwConversion |=IME_CMODE_NATIVE | IME_CMODE_KATAKANA;
DwConversion & amp;=~ IME_CMODE_FULLSHAPE;
break;
Case _IME_AlphaHalf://half Angle the number
DwConversion & amp;=
~ (IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE | IME_CMODE_KATAKANA);
break;
Default:
break;
}
ImmSetConversionStatus (hImc dwConversion, dwSentence);
}
ImmReleaseContext (HWND, hImc);
}
CodePudding user response:
Takes time, Sleep (1000), and have found the reason,But I don't know why HIMC HIMC=ImmGetContext (HWND);
HImc always returns NULL, other processes cannot be obtained through ImmGetContext other window hImc
CodePudding user response:
Try to make this part function into a separate DLL