16,748
社区成员
发帖
与我相关
我的任务
分享
Function EnumChildWndProc(AhWnd: LongInt): String; stdcall;
Var
WndCaption: Array [0 .. 254] of char;
Begin
GetWindowText(AhWnd, WndCaption, 254);
Result := WndCaption;
End;
procedure TForm1.Button5Click(Sender: TObject);
Var
Hwnd: LongInt;
begin
EnumChildWindows(Hwnd, @EnumChildWndProc, 0);
end;
implementation
var
s : pchar;
{$R *.dfm}
Function EnumChildWndProc(AhWnd: LongInt): boolean; stdcall;
Var
WndCaption: Array [0 .. 254] of char;
Begin
GetWindowText(AhWnd, WndCaption, 254);
s := @WndCaption[0];//你可以把需要的数据传给已经定义的变量
Result := True; //该返回值将作为EnumChildWindows函数的返回值传给调用方
End;
procedure TForm2.Button1Click(Sender: TObject);
Var
Hwnd: LongInt;
r : boolean;
begin
s := nil;
Hwnd := self.Handle;
r := EnumChildWindows(Hwnd, @EnumChildWndProc, 0);
if r then
showmessage(strpas(s));
end;
procedure TForm1.Button5Click(Sender: TObject);
Var
Hwnd: LongInt;
str:string;
begin
str := EnumChildWindows(Hwnd, @EnumChildWndProc, 0);
end;