“另一窗口”,是同一个程序的,还是别个程序的另一窗口,<br>如果是别个程序的就看看吧<br>procedure TForm1.Button1Click(Sender: TObject);<br> function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br> var<br> buffer: array[0..255] of Char;<br> begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //找到发消息的目标窗口的目标控件<br> if StrPas(Buffer)='TEdit' then<br> begin<br> PInteger(lparam)^ := hwnd; 得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end;<br>var<br> Handle: Integer;<br> buffer: Array[0..1023] of Char;<br>begin<br> Handle := FindWindow(nil,'另个窗口名'); //就是窗口的Caption<br> if Handle<>0 then<br> begin <br> EnumChildWindows(Handle,@EnumChildWindowsProc,Integer(@Handle));<br> //如果找到就是Handle,如果没找到Handle,还是窗口<br> //下面这句是测试<br> SendMessage(Handle,WM_SETTEXT,0,Integer(pchar('Your String')));<br> end;<br>end;