In my application, we use Form as containers, then we make customized NativeWindow.
I need to show a popup with search textbox on it. Whenever I show this popup, my IME input would switch from Chinese/Japanese to English Mode. Based on articles like this, input context should be either per user or per thread, why would my input change within my same app? (I am testing on Windows 10)
I have tried to keep the main app active by doing this, this would prevent the input from switching, BUT then my search box will not get keyboard input anymore when I show it, so I cannot use this method:
protected override void WndProc(ref System.Windows.Forms.Message m) {
switch(m.Msg) {
case (int)WM.ACTIVATE:
if(m.WParam.ToInt64() == 1) {
UserMethods.SetActiveWindow(PopupOwner.Handle);
}
break;
}
base.WndProc(ref m);
}
It seems like the input switches as my active window changes. But my search box needs to grab keyboard, so I believe I have no chioce but to change the active window.
I have also tried to create my own input context, override CanEnableIme, and set ImeMode, none of these works perfectly, I can explain the details if that helps.
Note: my search box is a customized text editor, not the form textbox control; I made it handle IME input by processing system messages like this, but I am not modifying the input context, only reading from it.
How do I keep IME input mode stays the same when I change active window?
GetWindowThreadProcessIdreturn value.