Jump to content
alogrep

styleElements and font.color

Recommended Posts

HI.

I just can't get to change the text color of a statictext;

I have this code:

          num:=TStaticText.create(self);
          num.parent:=self;
          num.parentcolor:=false;
          num.StyleElements:=[];
          rect:=wc.boundsrect;
          num.caption:=' '+inttostr(lastnumnum)+' ';
          num.font.name:='Arial';
          num.font.color:=clred;

I have tried setting StyleElements to sefont, to seclient, and also left it alone (seclient, sefont, seborder)..

THe texct color is always black. They have made this really hard to change!

Anybody knows the "magic trick" to change the color on a runtime created statictext?

P.S. if the statictext is created at design time, Style Elements is all set (3), AND IT WORKS LIKE A CHARM.

Share this post


Link to post

Set the transparent property to false:

 

var
  num: TStaticText;
begin
 num:=TStaticText.create(self);
          num.parent:=self;
//          rect:=wc.boundsrect;
//          num.caption:=' '+inttostr(lastnumnum)+' ';
          num.caption:=' Test';
          num.font.name:='Arial';
          num.font.color:=clred;
          num.Transparent:=false;
end;

Edit. You have to use StyleElement only if your application is using VCL Styles.

Edited by Lajos Juhász
StyleElement

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×