CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2000
    Location
    Pasadena, CA
    Posts
    18

    Lightbulb How to get the Color endpoints of an Active Title Bar?

    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.

  2. #2
    Join Date
    Jul 2000
    Location
    Pasadena, CA
    Posts
    18

    And the Answer is....

    For anyone who cares, I found the answer at http://www.experts-exchange.com/Prog..._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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured