[Lazarus] How to obtain the color of a component?
Howard Page-Clark
hdpc at talktalk.net
Thu Oct 20 22:48:17 CEST 2011
On 20/10/11 4:57, Felipe Monteiro de Carvalho wrote:
> Hello,
>
> Is there any easy way to obtain the color of a component taking into
> considerating all the factors? aka, propagating ParentColor, resolving
> clDefault, etc.
>
> I have my TCDPageControl on top of a form, but for
> TCDPageControl.Color I get just clDefault, which turns out to be
> black. =( using Parent.GetDefaultColor(dcBrush) also returned black in
> Windows...
>
> If there is no easy way maybe we should add one?
>
I think it is possible since clDefault is TColor($20000000) and clBlack
is TColor($000000) there are situations where the most significant bits
of clDefault are lost and the two colours become identical.
I've found that the Object Inspector's default component editor for
colours seems at times to initialise colours to $000000 whatever the
component's constructor may have directed.
In these situations I've resorted to overriding the Loaded method to set
the desired value.
Howard
More information about the Lazarus
mailing list