掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
日本語入力モード時のOnChangeをするには? (ID:39709)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
>日本語入力がOnの場合、上にある数式入力欄に文字を入れると、セルの値も同時に変わります。 >このエクセルのような動きをしたいのですが、どうしたらよいでしょうか どんな入力状況であっても大丈夫なように対処するのは かなり面倒なことだと思う。 procedure TMemo.WndProc(var Msg: TMessage); var IMC: HIMC; Len: Integer; sCS: string; begin inherited; case Msg.Msg of WM_KILLFOCUS: Form1.Label1.Caption := Text; // (未確定中に)フォーカスが他に移った時 WM_LBUTTONDOWN, WM_IME_COMPOSITION: if (Msg.LParam and GCS_COMPSTR <> 0) // 未確定文字列の変更時 or(Msg.LParam and $ffff0000 <> 0) then begin // 未確定中にクリックでCARET移動した時 IMC := ImmGetContext(Handle); Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); SetLength(sCS, Len); ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(sCS), Len); Len := CharToByteLen(Text, SelStart); // CARET位置に未確定文字列を挿入 Form1.Label1.Caption := Copy(Text, 1, Len) + sCS + Copy(Text, Len+1, 1000); ImmReleaseContext(Handle, IMC); end else if Msg.LParam = 0 then begin // 未確定中に未確定文字列をすべて消した時 Form1.Label1.Caption := Text; end; CN_COMMAND: // IMEがOFFの状態での入力時 if TWMCommand(Msg).NotifyCode = EN_UPDATE{EN_CHANGE} then begin Form1.Label1.Caption := Text; end; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.