Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-12

How to obtain the "real" color of a control @runtime?

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

I'm trying to obtain the "real" color of a control (TEdit) at runtime. The color at design time is set to clDefault ($20000000), but I need to get the RGB value (which in this case should be $FFFFFF, since with the current theme the default color of a TEdit on my OS is white). I need this s I can have another control paint in that same color on it's canvas.

ColorToRGB just gave me $0, whic is not what I'm looking for.

Any hints?

Bart

Reply by email

Vojtěch Čihák
to Bart

Hi,
?
just tested on Qt. My TEdits are also white.
?
This line:
?
writeln(ColorToString(Edit1.Brush.Color));
?
writes out clWindow for default color (clDefault) and clRed for clRed. ?
Vojt?ch?

Reply by email

Mattias Gaertner
to Bart: I'm trying to obtain the "real" color of a control (TEdit) at runtime. The color at…
Show quoted text 8 lines
Hi, I'm trying to obtain the "real" color of a control (TEdit) at runtime. The color at design time is set to clDefault ($20000000), but I need to get the RGB value (which in this case should be $FFFFFF, since with the current theme the default color of a TEdit on my OS is white). I need this s I can have another control paint in that same color on it's canvas.

What platform, Lazarus version, widgetset?

ColorToRGB just gave me $0, whic is not what I'm looking for.

The background can be an image, gradient or whatever. So on some themes this might be the correct result.

Mattias

Reply by email

zeljko
to Mattias Gaertner
Mattias Gaertner wrote 19 lines
On Mon, 22 Dec 2014 18:49:58 +0100 Bart wrote: > Hi, > > I'm trying to obtain the "real" color of a control (TEdit) at runtime. > The color at design time is set to clDefault ($20000000), but I need > to get the RGB value (which in this case should be $FFFFFF, since with > the current theme the default color of a TEdit on my OS is white). > I need this s I can have another control paint in that same color on > it's canvas. What platform, Lazarus version, widgetset? > ColorToRGB just gave me $0, whic is not what I'm looking for. The background can be an image, gradient or whatever. So on some themes this might be the correct result.
No, clDefault is incorrect at any time. To obtain color we have:
     function GetColorResolvingParent: TColor;
     function GetRGBColorResolvingParent: TColor;

zeljko

Show quoted text 8 lines
Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Bart
to zeljko
zeljko wrote
No, clDefault is incorrect at any time. To obtain color we have: function GetColorResolvingParent: TColor; function GetRGBColorResolvingParent: TColor;

Thanks.

I'm trying to create an "overlay" for a TEdit which van display a TextHint property
(http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.StdCtrls.TCustomEdit.TextHint). Life would be so much easier if we could draw on the TEdit's canvas (or even if a TEdit could be the parent of some other TComponent.

Bart

Reply by email

zeljko
to Bart
Bart wrote 13 lines
On 12/23/14, zeljko wrote: > No, clDefault is incorrect at any time. To obtain color we have: > function GetColorResolvingParent: TColor; > function GetRGBColorResolvingParent: TColor; Thanks. I'm trying to create an "overlay" for a TEdit which van display a TextHint property (http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.StdCtrls.TCustomEdit.TextHint). Life would be so much easier if we could draw on the TEdit's canvas (or even if a TEdit could be the parent of some other TComponent.

Under Qt it's possible, but under eg gtk2 is pretty tricky. Don't know for carbon/cocoa and win32. Same applies for drawing over TEdit canvas.

z.

Reply by email