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

Parmod Kumar 1 Reputation point
2022-02-11T07:36:43.623+00:00

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.

173471-image.png

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
725 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,496 Reputation points Microsoft Vendor
    2022-02-25T07:54:38.403+00:00

    To reproduce, Just toggle your application with other application. When toggling back to your application, Chinese IME begin effective for the window.
    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 a ITfDocumentMgr.
    177744-image.png IMESample.cpp
    177821-image.png TextService.cpp

    Now, if you want, you can SetFocus to others for example a ITfDocumentMgr when WM_SETFOCUS. I have tested with following code.

    case WM_SETFOCUS:  
    	mgr.getTextService().setFocus(mgr.getTextService().getDocumentManager());  
    	return 0;