Hello Tony,
Because the .NET GDI+ uses the AARRGGBB color model, while the Windows
still uses the 00BBGGRR color model. Unfortunately, the property
CustomColors of ColorDialog didn't do this convertion internally, so you
must convert every argb value manuly. It's a known problem, I hope it will
be solved soon.
You may work around this by using the following static method
public static int ColorToColorref(Color clr)
{
return (clr.R + (clr.G << 8) + (clr.B << 16));
}
e.g.
customColors[0] = ColorToColorref(Color.Biege);
Be free to let me know if you have any questions on this issue, Thanks!
Kind regards,
Ying-Shen Yu [MSFT]
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
From: "Tony Lin" <(E-Mail Removed)>
Subject: CustomColors Property in ColorDialog control
Date: Thu, 7 Aug 2003 17:30:09 -0700
Newsgroups: microsoft.public.dotnet.framework.windowsforms
I am having trouble using the CustomColors property in the ColorDialog
control.
I have created an int array from ARGB values and assigned it to the
CustomColors property of
my ColorDialog control. AllowFullOpen has been set to true.
Yet when I execute ShowDialog, the boxes specified for custom colors
display only black.
Here's my code:
int[] customColors = new int[4];
customColors[0] = Color.Beige.ToArgb();
customColors[1] = Color.CadetBlue.ToArgb();
customColors[2] = Color.Chocolate.ToArgb();
customColors[3] = Color.DeepPink.ToArgb();
this.colorDialog.AllowFullOpen = true;
this.colorDialog.AnyColor = true;
this.colorDialog.CustomColors = customColors;
DialogResult dr = this.colorDialog.ShowDialog();
The ColorDialog displays 4 black squares and 12 white squares in the Custom
Colors section.
What am I doing wrong here?
Tony Lin
Fremont, CA
|