查找另外一个窗口的句柄: handle := FindWindow(nil,PChar('窗口的标题'));//查到窗体句柄
查找子窗体:childHandle := FindWindowEx(handle,0,'子窗体类','子窗体标题');
另外有个枚举子窗体的API,EnumChildWindows(主创体句柄,@回调函数,用户参数);
用这个函数需要自己写一个回调的函数,比如:
function EnumChildProc(ahWND:HWND; param:LPARAM):boolean; stdcall;
sendmessage(handle,message,wl,rl)
unit Unit1;
interface
uses Windows, Messages,Tlhelp32, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var a,b:PAnsiChar;
h:HWND;
begin
h:= FindWindow(nil,'abc.txt - 记事本');
h:= FindWindowEx(h,0,'edit',nil);
SendMessage(h,WM_SETTEXT,255,Integer(PChar('我来测试了')));
ShowMessage( IntToStr(h));
end;
Read the rest of this entry