How to enable & disable IME input for an application without changing PC IME language

I have created custom Edit boxs and they are part of single window (language C++)
I want to enable/start IME input only when I draw the text (type in editbox) else it should be disabled/stopped for my application without changing PC IME language as other Applications (word,notepad etc..) should work as expected.
I tried setting the Focus (setFocus(documentMgr) when we click in edit box , but in that case if we type without selecting the editbox then default microsoft IME window. also there is not API to disable the focus as in setFocus(documentMgr) document manager can not be null. Please see the attached image.
@Xiaopo Yang - MSFT :
I didn't find any option to attached the code, and would be difficult to explain without the complete code & .exe.
But you can try sample app: https://github.com/zupet/TSF-Test
I took the referenece from it and the only change is that I am drawing text in multiple rectangles (in same window , see the attached image)
Do I need to make some changes?
yes, In TSF Test.cpp _tWinMain() function Move line no. 56,57 to
g_tsfThreadMgr.InitTsfThreadMgr();
g_tsfTextStore = g_tsfThreadMgr.CreateTsfTextStore(hWnd);
line 52 above showWindow() as it should initialize before showwindow.
What‘s your problem? The program has itself input based on
WM_CHAR
. The Edit control which I create usingCreateWindowEx
uses default IME input.I have uploaded sample applications in github: https://github.com/divineaugustine/windowsime
there are 2 sample app lication, please use IMEsample1
Problem description:
I am looking a solution for this, I should get IME text only when i click in editbox previous typed chars shouldn't get prepend, hence there should a way to tell TSF when to send and not to send text to application
Sign in to comment
1 answer
Sort by: Most helpful
To reproduce, Just toggle your application with other application. When toggling back to your application, Chinese IME begin effective for the window.
IMESample.cpp
TextService.cpp
Then I try a blank window project. English IME and Chinese IME both are effective for the window which should be a expected behavior.
But Why cannot Chinese IME take effect when your application starting? You
SetFocus
to aITfDocumentMgr
.Now, if you want, you can
SetFocus
to others for example aITfDocumentMgr
whenWM_SETFOCUS
. I have tested with following code.Thanks for the response
did you try below steps IMESample1:
If you are able to reproduce the issue in IMESample1 and try the same in IMESample2 as i did some fixes.
I have tried below solution, but I are not sure if this the right way to do it.
Please see the IMESample2, kindly take the latest code we did some changes.
Creating 2 document managers and switching the focus.
only for 1 document manager (created in textStore )we are creating the context and passing ITextStoreACP object
so, when we want a callbacks and want to draw text we set focus to 1st document manager else we setting focus to 2nd document manager (created in textService ) which does not have any context, hence we don’t get any callback.
This approach is working fine, we are able to reset the focus & composition text between 2 edit boxs and not getting any callback when don’t want to draw.
I tried and cannot reproduce until I toggle the window with the other. I'm trying to consult someone about whether this is the right way or not.
After consulting, Setting the input focus to the specified document manager is suitable for the document manager to take charging of input.
Sign in to comment
Activity