1,184
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;
var
buffer: array[0..255] of Char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
PInteger(lparam)^ := hwnd;
Result:=False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Handle: Integer;
begin
Handle := FindWindow(nil,'新建 文本文档 - 记事本');
if Handle<>0 then
begin
EnumChildWindows(Handle,@EnumChildWindowsProc,Integer(@Handle));
SendMessage(Handle,WM_SETTEXT,0,Integer(pchar('这是我的文本')));
end;
end;
end.
这个我测试过,你试试看!