Board index » delphi » Make contents of disabled control look disabled

Make contents of disabled control look disabled

I put controls on a panel or group box so that I can do something to the
group as a whole with one statement. Unfortunately this does not work well
for Enabled := false; or Enabled := true;  While the contents of the group
are effectively disabled, they do not LOOK disabled. Short of tossing out
the container and just enabling/disabling each individual control, is there
a way to make each control inside some container LOOK disabled when the
container is disabled?

Thanks,

Jon

 

Re:Make contents of disabled control look disabled


Quote
> I put controls on a panel or group box so that I can do something to the
> group as a whole with one statement. Unfortunately this does not work well
> for Enabled := false; or Enabled := true;  While the contents of the group
> are effectively disabled, they do not LOOK disabled. Short of tossing out
> the container and just enabling/disabling each individual control, is there
> a way to make each control inside some container LOOK disabled when the
> container is disabled?

No.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:Make contents of disabled control look disabled


Quote
Jon Jacobs wrote in message <7bj6tf$1...@forums.borland.com>...
>I put controls on a panel or group box so that I can do something to the
>group as a whole with one statement. Unfortunately this does not work well
>for Enabled := false; or Enabled := true;  While the contents of the group
>are effectively disabled, they do not LOOK disabled. Short of tossing out
>the container and just enabling/disabling each individual control, is there
>a way to make each control inside some container LOOK disabled when the
>container is disabled?

// Note: EnableChildren and EnableControl are mutually recursive !!
// loops through child controls calling EnableControl for each
procedure EnableChildren(ctl: TControl; Value: Boolean);
var i: integer;
begin
  if ctl is TWinControl then
    for i := 0 to pred(TWinControl(ctl).ControlCount) do
      EnableControl(TWinControl(ctl).Controls[i], Value);
end;

// sets passed control, then propagates setting to child controls
procedure EnableControl(ctl: TControl; Value: Boolean);
begin
  ctl.Enabled := Value;
  if ctl is TWinControl then
    EnableChildren(ctl, Value);
end;

You can call either function, calling the first will set all the children,
calling the second will *also* set the passed control as well as the
children.

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
"You know you've landed gear-up when it takes full power to taxi"

Other Threads