0

I am using Flutter to develop a Windows program, Need to disable input method, Find the relevant documentation, you can use the ImmDisableIME(0) method to disable the input method. But when I try to call this method, An exception was reported when running the project.

main.cpp

win32_window.cpp

How to properly disable the input method?

1
  • I'll answer the question anyway, but in general, please don't post links or pictures of code. Inline the code directly as text along with the error messages. Commented Sep 26, 2022 at 7:01

1 Answer 1

0

An exception was reported when running the project

No. An exception was not reported when running the project. Rather, your program never ran to begin with because it had a compiler error.

Because you are passing -1 to a function expecting an unsigned integer (DWORD), the compiler is warning you (C4245). And your build environment treats warnings as errors (C2220).

To invoke it with -1 such that it disables for all threads in the current process, then invoke it as follows with a cast. It's as easy as that.

DWORD dwParam = (DWORD)(-1);
ImmDisableIME(dwParam);
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much for your reply. A lot of websites mentioned that the parameter should simply be -1 to disable all threads in this process. link. I tried using 0 or 1 but it still produces the error.
main.obj : error LNK2019: �޷��������ⲿ���� ImmDisableIME������ wWinMain �������˸÷��� [W:\WorkSpace\RouXinPai\workpad\build\windows\runner\workpad.vcxproj] W:\WorkSpace\RouXinPai\workpad\build\windows\runner\Debug\workpad.exe : fatal error LNK1120: 1 ���޷��������ⲿ���� [W:\WorkSpace\RouXinPai\workpad\build\windows\runner\workpad.vcxproj] Exception: Build process failed.
You are correct. -1 means "disable for all threads in the process". Hence use a cast. I've updated my answer above, but effectively you can call it as: ImmDisableIME((DWORD)-1);
After inquiring some information, finally disabled the input method. First, add #pragma comment(lib, "imm32.lib") to the header of the win32_window.cpp file, Then call the ImmDisableIME(GetCurrentThreadId()) method. Thank you for your help.&( ^___^ )&

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.