Board index » delphi » Re: ParentColor on a colored button

Re: ParentColor on a colored button


2003-07-17 11:00:52 PM
delphi106
"Hoffmann" <XXXX@XXXXX.COM>writes
Quote
I have a colored button which ParentColor property is not working. How can
fix that?
.ParentColor isn't being assigned to in .Create, is it?
Cheers,
Ignacio
 
 

Re: ParentColor on a colored button

No, it is not. In fact I have a procedure to draw it but I don't know how to get the parent color.
"Ignacio Vazquez" <ivazquezATorioncommunications.com>writes:
Quote
"Hoffmann" <XXXX@XXXXX.COM>writes
news:3f16b843$XXXX@XXXXX.COM...
>I have a colored button which ParentColor property is not working. How can
fix that?

..ParentColor isn't being assigned to in .Create, is it?

Cheers,
Ignacio


 

Re: ParentColor on a colored button

I know it looks easy, but I can't get the value using
(AOwner as TControl).Color
I don't know why, the identifier "color" is not available.
Thanks.
"Ignacio Vazquez" <ivazquezATorioncommunications.com>writes:
Quote
"Hoffmann" <XXXX@XXXXX.COM>writes
news:3f16bf20$XXXX@XXXXX.COM...
>No, it is not. In fact I have a procedure to draw it but I don't know how
to get the parent color.

You can get it via TControl(Parent).Color.

Cheers,
Ignacio


 

Re: ParentColor on a colored button

Sorry Ignacio, but I didn't get it. I have never used the .Loaded, and I don't know how to do it.
Could you show me a specific example?
My component starts with:
TColorBtn = class(TButton)
Thank you for your attention.
Quote
That's because it is protected. You need to do it as so:

type
THackedControl=class(TControl)
end;

begin
Color:=THackedColor(...).Color;
end;

And you do want Parent in there, not AOwner. Do it in .Loaded.

Cheers,
Ignacio


 

Re: ParentColor on a colored button

"Hoffmann" <XXXX@XXXXX.COM>writes
Quote
Could you show me a specific example?

My component starts with:

TColorBtn = class(TButton)
type
TColorBtn=class(TButton)
protected
procedure Loaded; override;
end;
procedure TColorBtn.Loaded;
type
THackedControl=class(TControl);
begin
Color:=THackedControl(Parent).Color;
end;
Cheers,
Ignacio
 

Re: ParentColor on a colored button

"Ignacio Vazquez" <ivazquezATorioncommunications.com>writes:
Quote
"Hoffmann" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>Could you show me a specific example?
>
>My component starts with:
>
>TColorBtn = class(TButton)

type
TColorBtn=class(TButton)
protected
procedure Loaded; override;
end;

procedure TColorBtn.Loaded;
type
THackedControl=class(TControl);
begin
Color:=THackedControl(Parent).Color;
end;

Cheers,
Ignacio


 

Re: ParentColor on a colored button

Sorry for the last message.
The component works properly at run time. It does not have the same behaviour at design time, but it is ok.
Thank you for your help.