[Lazarus] How to obtain the color of a component?

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Fri Oct 21 10:01:58 CEST 2011


On Fri, Oct 21, 2011 at 9:47 AM, Paul Ishenin <ip at kmiac.ru> wrote:
> Why do you use Parent. ?

That's the whole reason why I have this problem at all. My control in
question here is TCDPageControl, which is a custom drawn page control,
therefore I have no background color of my own (although the user
might specify one), there are no native themes for my control nor
clDefault makes any sense for it, I just want to obtain the color of
my parent, so that I can make my control paint the same color that he
has, which is the form in this case, but it could be anything.

Now, regarding your suggestion, no it does not work:

procedure TCDCustomTabControlDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
  FPImg: TLazIntfImage);
var
  lColor: TColor;
  lFPColor: TFPColor;
  x, y: Integer;
begin
  if CDTabControl.Color = clDefault then
    lColor := CDTabControl.GetDefaultColor(dctBrush) <-- I get black!
  else lColor := ColorToRGB(CDTabControl.Color);

  // Background
  lFPColor := TColorToFPColor(lColor);
  FPImg.FillPixels(lFPColor);
end;

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list