Free Pascal => Beginners => Topic started by: JLWest on November 22, 2020, 05:31:18 am
Title: {Solved)TCanvas Question
Post by: JLWest on November 22, 2020, 05:31:18 am
I have a box on a form and would the color something different that the standard colors.
Is this doable.
Title: Re: TCanvas Question
Post by: lucamar on November 22, 2020, 05:49:43 am
Do you mean something like a TGroupBox or alike? Then yes, with some caveats: it might work if you just change its Color (and Font.Color) property to whatever you want, but the borders will still be drawn by the system and colored according to the theme and the same might happen with the controls inside, depending on the control.
If that doesn't work then you might be able to do it in a handler for its OnPaint event ... if the control has it! Which TGroupBox, for example, haven't.
Title: Re: TCanvas Question
Post by: JLWest on November 22, 2020, 06:04:38 am
Year in an onPaint event. It a box drawn in the onpaint event and then some buttons in the box/ I woul like the background a different color tjat the dark colors of the pallet.
Title: Re: TCanvas Question
Post by: lucamar on November 22, 2020, 07:05:50 am
So you're drawing the box by yourself already? Then just set the color of its brush/pen to whatever you want, like:
BoxCanvas.Brush.Color:= clWhite;{or whatever color you want}
if you're using, say, MyCanvas.FillRect() to draw it.
Title: Re: TCanvas Question
Post by: JLWest on November 22, 2020, 08:30:26 am
@Lucamar - Hope your doing good - staying safe.
Thanks for the reply. Yea, that's the way I'm doing it now. But all of those colors are really dark heavy colors. I'm looking for something like the CLlime but way lighter, just a light shade of lime.
Title: Re: TCanvas Question
Post by: dbannon on November 22, 2020, 12:36:25 pm
BoxCanvas.Brush.Color := $FFFFDD; // pale blue
Its RRGGBB as hex numbers, $FFFFFF is all black, $000000 is all white. Just experiment a bit to get the colour you want.
Davo
Title: Re: TCanvas Question
Post by: wp on November 22, 2020, 01:03:19 pm
Hex numbers - correct. But be careful with the byte order: I always remember (and I checked it again) that red is 255, i.e. $0000FF. Therefore the order of bytes in this hex number is $BBGGRR (opposite to html).
Title: Re: TCanvas Question
Post by: JLWest on November 22, 2020, 04:53:38 pm
@dbanon
The light blue was perfect.
Thanks all
Title: Re: TCanvas Question
Post by: winni on November 22, 2020, 06:50:09 pm
Hi!
If you want to learn about colors you can play around with: