[Lazarus] How to obtain the color of a component?
Paul Ishenin
ip at kmiac.ru
Fri Oct 21 09:47:26 CEST 2011
20.10.2011 23:57, Felipe Monteiro de Carvalho wrote:
> Is there any easy way to obtain the color of a component taking into
> considerating all the factors? aka, propagating ParentColor, resolving
> clDefault, etc.
if AControl.Color = clDefault then
AColor := AControl.GetDefaultColor(dctBrush)
else
AColor := AControl.Color;
Also you can check brush color: TWinControl.Brush.Color.
> 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...
Why do you use Parent. ?
> If there is no easy way maybe we should add one?
If color is default it means that it may not have a solid fill at all.
For example what color does a button has on themed windows if it is
painted using bitmap? Same for other widgetsets. No way to detect the
real color if it is default.
Best regards,
Paul Ishenin.
More information about the Lazarus
mailing list