It’s my guess that your problem is in the SetEnabled method. You
must’ve re-defined FEnabled in your derived component otherwise you
would be getting a compiler error since FEnabled is part of the private
section of TControl. Without knowing exactly what you did, here’s what
you should do to properly implement SetEnabled:
[code lang=”delphi”]TMyGroupBox = class(TGroupBox)
protected
procedure SetEnabled(Value: Boolean); override;
end;
procedure TMyGroupBox.SetEnabled(Value: Boolean);
begin
If Value <> Enabled Then
Invalidate;
Inherited;
end;
[/code]
**HOWEVER**
You should not even have to do that. The control should invalidate
itself anytime Enabled is changed. This is done via the
CMEnabledChanged message and handler.
Doing what you did below probably “disabled” (pardon the pun) the entire
Enabled property mechanism, which is why your text wouldn’t draw
correctly. (The component was never actually disabled.)
– Just a guess smile
Mike
[tags]Delphi, Components[/tags]
0 Kommentare zu “Override “Enabled”-property in own components”