var
HIC : HIMC;
Buffer : pchar;
BufferLen : DWORD;
begin
Result := '';
HIC := ImmGetContext(Form1.handle);
if hIC = 0 then Exit;
BufferLen := ImmGetCompositionString(hIC, GCS_RESULTSTR, nil, 0);
if BufferLen <= 0 then Exit;
GetMem(Buffer, BufferLen +1);
try
if ImmGetCompositionString(HIC, GCS_RESULTSTR, Buffer, BufferLen) > 0 then
begin
Result := StrLCopy(Buffer, Buffer, BufferLen);
end;
finally
FreeMem(Buffer, BufferLen +1);
ImmReleaseContext(Form1.handle, HIC);
end;
end;它可以得到中文,但是如果不键入新的字时,总反会上次的结果,能不能只得到一次结果?
HIC : HIMC;
Buffer : pchar;
BufferLen : DWORD;
begin
Result := '';
HIC := ImmGetContext(Form1.handle);
if hIC = 0 then Exit;
BufferLen := ImmGetCompositionString(hIC, GCS_RESULTSTR, nil, 0);
if BufferLen <= 0 then Exit;
GetMem(Buffer, BufferLen +1);
try
if ImmGetCompositionString(HIC, GCS_RESULTSTR, Buffer, BufferLen) > 0 then
begin
Result := StrLCopy(Buffer, Buffer, BufferLen);
end;
finally
FreeMem(Buffer, BufferLen +1);
ImmReleaseContext(Form1.handle, HIC);
end;
end;它可以得到中文,但是如果不键入新的字时,总反会上次的结果,能不能只得到一次结果?
解决方案 »
- delphi能否实现隐私浏览保护功能?
- 怎么把这代码改成批量更新
- 一个服务程序读取INI文件,并且创建新窗体,新窗体如何取得服务程序的INI数据?在线等待
- 错误提示:No parentchart to validate DataSource.谁能帮我?Thanks!
- 探讨短信软件开发原理
- CHART中的一个简单问题
- pascal 语言和C 语言编写的程序之间相互调用时,参数类型是否可以传递结构和链表
- 如何根据年月日得到星期几?
- DELPHI有没有根据窗口名或则对应的类名(字符串)打开窗口的函数
- 罗刚事件当晚录音http://www.91pop.com/upfile/31_1012.mp3
- 如何学习DELPHI?
- 一个时间问题?
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,imm;
type
TForm3 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject); private
FDefEditProc: TWndMethod;
procedure EditWndProc(var Message: TMessage);
public
end;var
Form3: TForm3;implementation
{$R *.dfm}uses unit2;procedure TForm3.EditWndProc(var Message: TMessage);
begin
if Message.Msg = WM_IME_COMPOSITION then
Edit2.Text:=form2.GetIME; //这里加入你的function
if Message.Msg = WM_KEYDOWN then
Edit2.Clear; //及时清空.
FDefEditProc(Message);
end;
procedure TForm3.FormDestroy(Sender: TObject);
begin
Edit1.WindowProc := FDefEditProc;
end;procedure TForm3.FormShow(Sender: TObject);
begin
FDefEditProc := Edit1.WindowProc;
Edit1.WindowProc := EditWndProc;
end;end.
var
ImeList:TStrings;
begin
ImeList:=TStringLlist.create;
ImeList.Assign(screen.Imes);//ImeList中就有你系统中所有的输入法呢!
end;
http://www.csdn.net/Develop/Article/15/15556.shtm
var
IMEContext: HIMC;
P: PChar;
Size: Integer;
begin NewString:='';
if (Message.LParam and GCS_RESULTSTR) <> 0 then
begin
IMEContext := ImmGetContext(Handle);
try
Size := ImmGetCompositionString(IMEContext, GCS_RESULTSTR, nil, 0);
Inc(Size, 1); //加2还是加1
GetMem(P,Size);
try
ImmGetCompositionString(IMEContext, GCS_RESULTSTR, P, Size);
P[Size] := #0;
NewString:=P;
finally
FreeMem(P);
end;
finally
ImmReleaseContext(Handle, IMEContext);
end;
Message.Result := 0;
end
else inherited;
end;
newstring 就是了