以前(id:TakamiChie:20070120:1169317284)悩んでいたIME制御の件ですが、無事解決しました。
――ということで、Windowsと同じく、Imm系のAPIを呼出せばOK。ここから先はWindowsのプログラミングTipsサイトを見ればすぐ解決しますね。
IntPtr context = ImmGetContext(hWnd); try { int conv = 0; int sentence = 0; ImmGetConversionStatus(context, ref conv, ref sentence); ImmSetConversionStatus(context, /*ここに新しい変換コードを指定*/, sentence); } finally { ImmReleaseContext(hWnd, context); }
APIの宣言については上記のスレッドにもありますが、
[DllImport("Coredll.dll", SetLastError = true)] private static extern IntPtr ImmGetContext(IntPtr hWnd); [DllImport("Coredll.dll", SetLastError = true)] private static extern bool ImmReleaseContext(IntPtr hWnd, IntPtr hIMC); [DllImport("Coredll.dll", SetLastError = true)] private static extern bool ImmGetConversionStatus(IntPtr hIMC, ref int fdwConversion, ref int fdwSentence); [DllImport("Coredll.dll", SetLastError = true)] private static extern bool ImmSetConversionStatus(IntPtr hIMC, int fdwConversion, int fdwSentence);
と書いておきましょう。数字入力にする場合はImmSetConvertStatusにIME_CMODE_ALPHANUMERIC(0x00)を指定すればOK。
本当に何でもCoredll.dllにまとまってるんですね。何が使えて何が使えないのか、どこかに一覧でもないものでしょうか*1。
*1:DLLをコアダンプすればいいのでしょうか。どこかでそんな話を聞いたなあ