首先你要通过Handle获得该窗体的控件地址,看看下面这个函数:Function FindForm(hWnd:THANDLE):TForm; var i:Integer; Begin Result := nil; for I := 0 to Application.ComponentCount -1 do if Application.Components[i] is TForm then if (Application.Components[i] as TForm).Handle = hWnd then Begin Result := (Application.Components[i] as TForm); break; end; end;
还写丢了一部分: //这个函数是通过句柄查找是哪个窗体; function FindForm(hWnd:THANDLE):TForm; var i:Integer; Begin Result := nil; for I := 0 to Application.ComponentCount -1 do if Application.Components[i] is TForm then if (Application.Components[i] as TForm).Handle = hWnd then Begin Result := (Application.Components[i] as TForm); break; end; end;找到窗体后,可以利用TForm的Components属性来发现它上面的控件。调用例子:var TempFrm:TForm; i:integer; begin TempFrm := FindForm(Handle); if Assigned(TempFrm) then for I:=0 to TempFrm.ComponentCount - 1 do Memo1.Lines.Add(TempFrm.Components[i].ClassName); end;
var
i:Integer;
Begin
Result := nil; for I := 0 to Application.ComponentCount -1 do
if Application.Components[i] is TForm then
if (Application.Components[i] as TForm).Handle = hWnd then
Begin
Result := (Application.Components[i] as TForm);
break;
end;
end;
//这个函数是通过句柄查找是哪个窗体;
function FindForm(hWnd:THANDLE):TForm;
var
i:Integer;
Begin
Result := nil; for I := 0 to Application.ComponentCount -1 do
if Application.Components[i] is TForm then
if (Application.Components[i] as TForm).Handle = hWnd then
Begin
Result := (Application.Components[i] as TForm);
break;
end;
end;找到窗体后,可以利用TForm的Components属性来发现它上面的控件。调用例子:var
TempFrm:TForm;
i:integer;
begin
TempFrm := FindForm(Handle); if Assigned(TempFrm) then
for I:=0 to TempFrm.ComponentCount - 1 do
Memo1.Lines.Add(TempFrm.Components[i].ClassName);
end;