实现如下:
void LoginDlg::onPasswordFocusChanged(bool isfocus)
{
HWND wnd = (HWND)this->winId();
if (isfocus)
{
//focus on
hIMC_ = ::ImmGetContext(wnd);
if(hIMC_)
{
ImmAssociateContext(wnd, nullptr);
ImmReleaseContext(wnd, hIMC_);
}
return;
}
else
{
//focus out
if (hIMC_)
{
ImmDestroyContext(hIMC_);
hIMC_ = nullptr;
}
hIMC_ = ImmCreateContext();
if (hIMC_)
{
ImmAssociateContext(wnd, hIMC_);
ImmReleaseContext(wnd, hIMC_);
}
}
......
}
hIMC_的定义如下:
HIMC hIMC_;