Hi, Eli,

I modifed the code following your instruction.  I added some more comments on functions. Test is done, IME status changes as expected.

I used GetFocus() in w32_msg_pump() now.

But I can't invoke GetFocus() in w32-get-ime-open-status(), because w32-get-ime-open-status() is invoked in lisp thread. I just use w32_system_caret_hwnd instead, if get_ime_context_fn(w32-get-ime-open-status) returns NULL, w32-get-ime-open-status() return nil.

Attachement is the modifed patch.

------------------ 原始邮件 ------------------
发件人: "Albert"<georgealbert@qq.com>;
发送时间: 2020年4月13日(星期一) 下午3:26
收件人: "Eli Zaretskii"<eliz@gnu.org>;
抄送: "emacs-devel"<emacs-devel@gnu.org>;
主题: 回复: 回复: 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively

Hi, Eli,

I can't get the main window handle as emacs doesn't save the main window handle after invoking createWindow(). I just found w32_system_caret_hwnd did work. I will modify the code by using GetFocus().


------------------ 原始邮件 ------------------
发件人: "Eli Zaretskii"<eliz@gnu.org>;
发送时间: 2020年4月13日(星期一) 下午3:21
收件人: "Albert"<georgealbert@qq.com>;
抄送: "emacs-devel"<emacs-devel@gnu.org>;
主题: Re: 回复: 回复: 回复: 回复: [PATCH] Add IME status change support on windows natively

> From: "Albert" <georgealbert@qq.com>
> Cc: "emacs-devel" <emacs-devel@gnu.org>
> Date: Mon, 13 Apr 2020 15:07:19 +0800
>
> Thanks. I'll try it.

I'm also worried by your use of w32_system_caret_hwnd as the handle of
the window for which to retrieve the input context.
w32_system_caret_hwnd is not guaranteed to be a valid handle if the
system caret is not used, i.e. if w32-use-visible-system-caret is nil
(which is the default).

So perhaps instead of using w32_system_caret_hwnd, you should use the
return value of GetFocus function, similar to what we do elsewhere in
w32_msg_pump.