mjk6026
mjk6026

Reputation: 1484

ImmGetContext return 0 in WPF

in WPF Window,

        WindowInteropHelper h = new WindowInteropHelper(this);
        IntPtr hK = ImmGetContext(h.Handle);

ImmGetContext returns 0 always. In the contrary, In Windows Form, It works properly.

Upvotes: 1

Views: 1333

Answers (1)

jschroedl
jschroedl

Reputation: 4986

I believe we ran into this issue too.

For our app we ended up overriding WindowProc and use the hwnd which comes in there with WM_IME_COMPOSITION message and passing that to ImmGetContext().

We set up the WindowProc in OnSourceInitialized. (our code is c++/cli so this C# may not be exact)

var handle = new WindowInteropHelper( this ).Handle;
HwndSource.FromHwnd(handle).AddHook( new HwndSourceHook( WindowProc ) );

Upvotes: 3

Related Questions