Assigning Colors to a Font in a FontDialog

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Assigning Colors to a Font in a FontDialog

Postby Sparky » Wed Jul 07, 2004 9:56 am

I'm having trouble assigning a variable containing an RGB color to the TColor in a Font Dialog and having that color come up when the dialog is executed. The only format that works is:

Form1->FontDialog1->Font->Color = clLime;
Form1->FontDialog1->Execute();

but I need something like:

AnsiString FontColor;
Form1->FontDialog1->Font->Color = FontColor;
Form1->FontDialog1->Execute();

Can anyone help? Thanks so much in advance.

Sparky
Sparky
 

Postby Damon » Fri Jul 23, 2004 8:01 am

Hi Sparky,
You need your FontColor variable to be of type TColor; you can't directly assign an AnsiString to a TColor. Alternatively, you can use the StringToColor() function...

extern PACKAGE TColor __fastcall StringToColor(const AnsiString S);

that's part of the VCL Graphics unit.

Good luck,
Damon
User avatar
Damon
BCBJ Editor and Admin
BCBJ Editor and Admin
 
Posts: 285
Joined: Wed May 26, 2004 11:25 pm
Location: Stillwater, OK, USA


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 6 guests

cron