radlradl
April 14th, 2003, 11:19 PM
I'm writing a bunch of custom controls, and to keep with the style and feel of windows, I want to get the two endpoint colors so that my gradients look correct. Any ideas? And I already know the rgb values for the standard color scheme, that isn't what I need. I need a way to programically get the colors, so if the style changes, my controls will change right along with it. Thanks in advance, and props to anyone who can give me some insight into this problem. :)
radlradl
April 17th, 2003, 04:37 PM
For anyone who cares, I found the answer at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_11256974.html
Here's a little code snippet that will convert it into a Color that you can use in C#.
//----------------------------------------------------------------------
using System.Runtime.InteropServices;
[DllImport( "user32.dll", EntryPoint = "GetSysColor" )]
internal static extern long GetSysColor(long nIndex);
public static Color GetSystemGradientRightColor()
{
long right = GetSysColor(27);
byte blue = (byte)((right & 0x00ff0000) >> 16);
byte green = (byte)((right & 0x0000ff00) >> 8);
byte red = (byte)(right & 0x000000ff);
return Color.FromArgb(red, green, blue);
}
//----------------------------------------------------------------------
Hope this helps someone else too. :)