huhu,
über das "Controls" property kein problem. Hier mal 2 Varianten die ich benutze:
EDIT: Muss natürlich dahingehend angepasst werden das nur "TBitBtn" berücksichtigt wird...
Delphi-Quellcode:
procedure EnableDisalbeChildControls(const Enalbe: Boolean; ParentControl: TWinControl);
var
i: Integer;
begin
if Assigned(ParentControl) AND (ParentControl <> nil) then begin
for i := 0 to ParentControl.ControlCount-1 do begin
if not (ParentControl.Controls[i].InheritsFrom(TCustomPanel)
OR ParentControl.Controls[i].InheritsFrom(TCustomGroupBox)) then
ParentControl.Controls[i].Enabled := Enalbe;
if ParentControl.Controls[i] is TWinControl then
EnableDisalbeChildControls(Enalbe,
TWinControl(ParentControl.Controls[i]));
end;
end;
end;
procedure EnableDisalbeChildControls(const Enable: Boolean; ParentControl: TWinControl; ExceptThese: Array of TControl); overload;
var
i, j: Integer;
inExceptArr: Boolean;
begin
inExceptArr := False;
if Assigned(ParentControl) AND (ParentControl <> nil) then begin
for i := 0 to ParentControl.ControlCount-1 do begin
inExceptArr := False;
for j := Low(ExceptThese) to High(ExceptThese) do begin
inExceptArr := (Assigned(ExceptThese[j])) AND (ParentControl.Controls[i] = ExceptThese[j]);
if inExceptArr then
Break;
end;//check if in ExceptThese-Array
if not (ParentControl.Controls[i].InheritsFrom(TCustomPanel)
OR ParentControl.Controls[i].InheritsFrom(TCustomGroupBox))
AND (not inExceptArr) then
begin
ParentControl.Controls[i].Enabled := Enable;
end;
if ParentControl.Controls[i] is TWinControl then
EnableDisalbeChildControls(Enable,
TWinControl(ParentControl.Controls[i]), ExceptThese);
end;
end;
end;