[英]C++ Builder 2009 Iterate/Recurse through Components on a Form
我希望遍歷表單上的各個組件。
我計划遍歷各個組件,以對特定類型的組件進行批量更改,但是為此,我需要所有組件的句柄。
我檢查了Code Complete和Google,但是沒有回答我自己的問題的運氣。
使用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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.