...
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
KK:longint;
implementation
{$R *.dfm}
function GetAllWinProc(Hwnd:longint;Lparam:longint):Boolean;stdcall;
var WinTxt:Pchar;
begin
GetMem(WinTxt,255);
GetClassName(Hwnd,WinTxt,255);
if WinTxt = 'TEdit' then
begin
KK := KK+1;
Form1.ListBox1.Items.Add(IntToStr(Hwnd) + WinTxt);
if KK = 2 then
SetWindowText(Hwnd,'OK');
end;
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
KK:=0;
EnumChildWindows(Form1.Handle,Pointer(@GetAllWinProc),0);//如果操作别的进程
//那么将Form1.Handle换成你要操作的主窗口的句柄,注意,如果他的EDIT放在PANEL上,你就要将Form1.Handle改为PANEL的HANDLE,总之要是EDIT的PARENT的HANDLE。
运行上面的代码,你发现程序总将其中一个固定的EDIT内容设置为OK了!这样行了吧?
end;