帮帮你,可能用的上:<br>function findhnd(handle:thandle;lparam:lparam):boolean;stdcall;<br>var<br>l:integer;<br>name
char;<br>a:string;<br>buffer:array [0..255] of char;<br>begin<br>result:=true;<br> getclassname(handle,buffer,256);<br> a:=strpas(buffer);<br> if StrPas(buffer)='TButton' then //查找对应的类<br> begin<br> l:=sendmessage(handle,WM_GETTEXTLENGTH,0,0)+1;<br> GetMem(Name,L);<br> SendMessage(handle,WM_GETTEXT,l,integer(Name));<br> a:=strpas(name);<br> if strpas(name)='Button2' then //查找对应的名称<br> begin<br> pinteger(lparam)^:=handle;<br> result:=false;<br> end;<br> FreeMem(name,0);<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>hnd:thandle;<br>begin<br> hnd:=findwindow(nil,'Form2');<br> if hnd<>0 then<br> begin<br> EnumChildWindows(hnd,@findhnd,integer(@hnd));<br> sendmessage(hnd,WM_LBUTTONDOWN,0,0);<br> sendmessage(hnd,WM_LBUTTONUP,0,0);<br> end;<br><br>end;