Windows7 32bit VB.NET 2015でWPFクラスライブラリのDLLを作成しようとしています。
この中で日本語入力を行うテキストボックスがあり、ここにソフトキーボードから入力された平仮名の文字列が入っています。
最終的には、この平仮名に対する漢字変換候補の一覧をリストボックスに貼りつけたいのですが、一覧を取得するところで躓いています。
以下のコードを試作してみました。
VB
1 Dim Kana As String = "アイ" 2 Dim infoType As Object 3 4 infoType = {GCS_COMPCLAUSE, GCS_COMPREADCLAUSE, GCS_RESULTCLAUSE, GCS_RESULTREADCLAUSE} 5 6 'フォーカスを設定 7 textBox.Focus() 8 9 Dim winHandle As IntPtr 10 winHandle = New WindowInteropHelper(Me).Handle 11 12 Dim ret0 As Boolean 13 imeContext = ImmGetContext(hWnd) 14 ret0 = ImmSetOpenStatus(imeContext, True) 15 16 ret0 = ImmSetCompositionString(imeContext, SCS_SETSTR, 0, 0, Kana, Len(Kana)) 17 18 ret0 = ImmNotifyIME(imeContext, NI_COMPOSITIONSTR, CPS_CONVERT, 0) 19 20 ' 読みの文字列 21 Dim intLength As Integer 22 intLength = ImmGetCompositionString(imeContext, GCS_RESULTREADSTR, Nothing, 0) 23 24 Dim temp As New StringBuilder(intLength) 25 For i = 0 To UBound(infoType) 26 ImmGetCompositionString(imeContext, GCS_RESULTREADSTR, temp, intLength) 27 Next 28 29 bufferSize = ImmGetCandidateList(imeContext, 0, udtCandidateList, 0) 30 bufferSize = ImmGetCandidateList(imeContext, 0, udtCandidateList, bufferSize)
「ImmNotifyIME」まではリターン値にTrueが入り、正常終了していますが、
「ImmGetCompositionString」のリターン値が0になってしまいます。
何かIMEへの指定が間違っているのでしょうか。
ご教示をお願いいたします。
あなたの回答
tips
プレビュー