Setting Font.Color of a Label

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Setting Font.Color of a Label

Post by Phil Pendlebury » Wed Mar 21, 2012 3:05 pm

Greetings,

I am trying to change the font colour of a label "on the fly"

In the actual dilaog:

Code: Select all

Font.Color = clBlue
Works fine

But if I try and set it by a SetDialogProperty, for example:

Code: Select all


IF>a=1
  SetDialogProperty>Dialog1,Label4,Font.Color,clGreen
ELSE
  SetDialogProperty>Dialog1,Label4,Font.Color,clBlue
ENDIF
SetDialogProperty>Dialog1,Label4,Caption,MESSAGE!
It has no effect on the label's colour.

Is this simply not supported or am I missing something?

Thank you.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Wed Mar 21, 2012 3:13 pm

I have got around this by creating two identical labels on top of each other with the preset font colours.

Then making each label invisible / Visible depending on which colour I want to display.
Phil Pendlebury - Linktree

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Mar 21, 2012 3:26 pm

You have to use SetDialogObjectFont

Code: Select all

IF>a=1
  SetDialogObjectFont>Dialog1,Label4,MS Sans Serif,8,1,32768
ELSE
  SetDialogObjectFont>Dialog1,Label4,MS Sans Serif,8,1,16711680
ENDIF
SetDialogProperty>Dialog1,Label4,Caption,MESSAGE!

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Wed Mar 21, 2012 3:34 pm

Ok thanks Rain Great stuff.

I do quite like my solution though. Hehe.

But seriously, actually much easier to see what's going on as you can use proper colour names etc. Could even name labels as

object LabelGreen1: TLabel
object LabelBlue1: TLabel
etc.

There has to be a drawback though I suppose, there usually is when I feel like I had a good idea. :-)

See here:

http://www.mjtnet.com/forum/post31870.html#31870
Phil Pendlebury - Linktree

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts