我希望迭代/递归遍历表单上的组件。
我计划迭代/递归遍历组件,以对特定类型的组件进行批量更改,但为了这样做,我需要一个指向所有组件的句柄。
我检查了Code Complete和Google,但没有任何机会回答我自己的问题。
发布于 2013-12-15 03:09:20
使用TWinControl.Controls[]
属性,例如:
Procedure DoSomething(AControl: TWinControl);
Var
I: Integer;
Ctrl: TControl;
Begin
If AControl is TSomeControl then
Begin
...
End;
For I := 0 to AControl.ControlCount-1 do
Begin
Ctrl := AControl.Controls[I];
If Ctrl is TWinControl then
DoSomething(TWinControl(Ctrl));
End;
End;
Procedure TMyForm.DoIt;
Begin
DoSomething(Self);
End;
https://stackoverflow.com/questions/20575555
复制相似问题