delphi ݹȡӴԾGetChildWindows 
2009-05-08 16:26
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure GetChildWindows(h: HWND);
var
buf: array[0..255] of Char; {ǻȡõ, Ҫɾ}
begin
h := GetWindow(h, GW_CHILD); {һӴ}
while h <> 0 do
begin
    {ҪִеĲ, ٶֻ TEdit}
    GetClassName(h, buf, Length(buf));
    //if buf = 'TEdit' then
    ShowMessageFmt('%s:%d', [buf, h]);

    h := GetWindow(h, GW_HWNDNEXT); {һӴ}
    GetChildWindows(h);             {ݹ}
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
h:hwnd;
begin
h:=strtoint(edit1.Text);
GetChildWindows(h);


end;


end.

