Re: How to get rid of constant color names for colordialog customcolors





On Oct 24, 10:15 am, HanslH <n...@xxxxx> wrote:
delphi4

I want the custom colors in a color dialog to represent the colors
that are currently used in my application.
Since colordialog has a customcolors properties that's a tiny easy
little job.

Not.

The colors of my appliaction are stored in the registry as strings
with colortostr. Alas some colors are among the main constant named
colors and stored as such ('clwhite')
The colordialog only accepts customcolors as a stringlist as
'colora=$xxxxxxxx'
'colorb=$xxxxxxxx'

'colora=clWhite' is joyfully puked out

I cannot come up with anyway to get rid of these constant names. I've
been looking at identtocolor strtocolor etc functions.
It seems rather annoying that delphi sticks to these constant names
but on the other hand the dialog rejects them. But it must be
something i'm overlooking. Please put me out of my misery.

Use IdentToColor() function (and any other similar color transform
functions - see Help).

Something like ...

ColorValStr := '$ffffff; // or ColorValStr := clWhite;

if IdenttoColor(ColorValStr, ColorInt) then
CustColorValStr := Format('$8.8x', [ColorInt])
else
CustColorValStr := ColorValStr;
ColorDialog1.CustomColors.Add('ColorA=' + CustColorValStr);

Alan Lloyd

.



Relevant Pages