用WINDOWS消息。procedure TForm1.BitBtn1Click(Sender: TObject);
var
Handle: Integer;
tmpHandle: Integer;
FTextHandle :hwnd;
begin
Handle := FindWindow(nil,'发送消息'); 这个是发送消息时的的句柄
// Handle := FindWindow(nil,'对话模式');——这个是对话模式下的句柄
if handle<>0 then
begin
EnumChildWindows(tmpHandle,@GetEditHandle,Integer(@tmpHandle));
FTextHandle := tmpHandle;
SendMessage(FTextHandle,WM_SETTEXT,0,Integer(pchar(memo1.Text)));
//把MEMO1里的内容写到oicq消息框。
end;
end;
function GetEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;
var
buffer: array[0..255] of Char;
buffer1: array[0..255] of Char;
str:pchar;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
GetWindowText(hwnd,buffer1,100);
PInteger(lparam)^ := hwnd;
Result:=False;
end;
end;其实可以写在TIMER构件里,然后改为对话模式就更好了。
没有具体调试过,有错误请说。
var
Handle: Integer;
tmpHandle: Integer;
FTextHandle :hwnd;
begin
Handle := FindWindow(nil,'发送消息'); 这个是发送消息时的的句柄
// Handle := FindWindow(nil,'对话模式');——这个是对话模式下的句柄
if handle<>0 then
begin
EnumChildWindows(tmpHandle,@GetEditHandle,Integer(@tmpHandle));
FTextHandle := tmpHandle;
SendMessage(FTextHandle,WM_SETTEXT,0,Integer(pchar(memo1.Text)));
//把MEMO1里的内容写到oicq消息框。
end;
end;
function GetEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;
var
buffer: array[0..255] of Char;
buffer1: array[0..255] of Char;
str:pchar;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
GetWindowText(hwnd,buffer1,100);
PInteger(lparam)^ := hwnd;
Result:=False;
end;
end;其实可以写在TIMER构件里,然后改为对话模式就更好了。
没有具体调试过,有错误请说。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货