以前的小程序,用这个回调API(EnumChildWindows)可以解决你的问题:<br>下面是小例子:<br>function GetCtrlHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> Buffer : array [0..255] of Char;<br> Buffer1: array [0..255] of Char;<br> Buffer2: array [0..255] of Char;<br>begin<br> Result := true;<br> GetClassName(hwnd,Buffer,256);<br> GetWindowText(hwnd,Buffer1,100);<br> if StrPas(Buffer) = 'Edit' then<br> LastEditHandle := hwnd;<br> if StrPas(Buffer) = 'TFlatButton' then<br> Begin<br> GetWindowText(hwnd,Buffer2,100);<br> if Buffer2 = '发言(&S)' then<br> SendHandle := hwnd;<br> end;<br> PInteger(lparam)^ := hwnd;<br> if Trim(StrPas(Buffer)) = '' then<br> begin<br> Result := false;<br> Exit;<br> end;<br> form1.Show(IntToStr(hwnd),StrPas(Buffer1),StrPas(Buffer));<br>end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> Button1.Enabled := false;<br>// WinHandle := FindWindow(nil,'幻灵游侠 beta 测试版');<br>// WinHandle := FindWindow(nil,'幻灵游侠');<br> WinHandle := FindWindow(nil,'聊天');<br> if WinHandle = 0 then<br> begin<br> ShowMessage('没有打开幻灵吧?找不到这个窗体');<br> Button1.Enabled := true;<br> Exit;<br> end;<br> List1.Clear;<br> whichList := 1;<br> EnumChildWindows(WinHandle,@GetCtrlHandle,Integer(@WinHandle));<br> Button1.Enabled := true;<br>end;