上次寫了一個UI的控件editbox,我采用了IME響應中文輸入,但在消息處理的時候收到WM_INPUTLANGCHANGEREQUEST,卻沒收到WM_INPUTLANGCHANGE的消息,在網上也查不到原因,看MSDN一開始也沒看出原因。但實際上是我自己沒能理解MSDN所說的。
The
WM_INPUTLANGCHANGEREQUEST message is posted to the window with the focus when the user chooses a new input language, either with the hotkey (specified in the Keyboard control panel application) or from the indicator on the system taskbar. An application can accept the change by passing the message to the
DefWindowProc function or reject the change (and prevent it from taking place) by returning immediately.
實際上這段話的意思是,收到了
WM_INPUTLANGCHANGEREQUEST后,要把該消息發送給
DefWindowProc,才能收到輸入法的改變消息。
我原來的代碼是:
BOOL WndProc()
{
switch (msg)
{
}
return 0;
}
后來改為:
BOOL WndProc()
{
switch (msg)
{
}
return DefWindowProc(......);
}
就沒問題了!所以一定要充分理解MSDN所說的。