> 请您试一下<br>Oh, 我试过的!<br>> 双字节字符有问题<br>能具体点吗?<br>> 如何得到当前光标所在的焦点呢<br>调用 API 函数:<br> hFocus := GetFocus;<br>> 如果没有焦点<br>如果没有焦点,那么无法输入,<br> 除非是指定需输入的控件(Window)的 Handle<br> SendDBCSString(Memo1.handle, '你好!');<br><br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, Buttons;<br><br>type<br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> Edit1: TEdit;<br> SpeedButton1: TSpeedButton;<br> SpeedButton2: TSpeedButton;<br> procedure SpeedButton1Click(Sender: TObject);<br> procedure SpeedButton2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure SendDBCSString(hFocus: HWND; const sSend: string);<br>var<br> hActiveControl: HWND;<br> i: integer;<br> ch: byte;<br>begin<br> if hFocus = 0 then hFocus := GetFocus;<br> if hFocus = 0 then Exit;<br> i := 1;<br> while i <= Length(sSend) do<br> begin<br> ch := byte(sSend);<br> if Windows.IsDBCSLeadByte(ch) then<br> begin<br> Inc(i);<br> SendMessage(hFocus, WM_IME_CHAR, MakeWord(byte(sSend), ch), 0);<br> end<br> else<br> SendMessage(hFocus, WM_IME_CHAR, word(ch), 0);<br> Inc(i);<br> end;<br>end;<br><br>procedure TForm1.SpeedButton1Click(Sender: TObject);<br>begin<br> SendDBCSString(0, '¥');<br>end;<br><br>procedure TForm1.SpeedButton2Click(Sender: TObject);<br>begin<br> SendDBCSString(Memo1.Handle, '¥');<br>end;<br><br><br>end.