How to determine Windows XP Color Scheme

Hello,

Does anyone know how to determine the windows xp color scheme at runtime  I need to know if the user is using blue, silver, or olive to customize a control based on their color scheme...

Thanks,
Anthony


Answer this question

How to determine Windows XP Color Scheme

  • Amrish Deep Ravidas

    Be aware that there are a lot of users with customized themes (StyleXP). What do you want to do in the event that they are not using a standard theme

    The following vb.net code will do what you ask.

    Imports System.Runtime.InteropServices
    Imports System.Text

    <DllImport("uxtheme", CharSet:=CharSet.Unicode, CallingConvention:=CallingConvention.Cdecl)> _
    Private Shared Function GetCurrentThemeName( _
                ByVal pszThemeFileName As StringBuilder, _
                ByVal cchMaxNameChars As Integer, _
                ByVal pszColorBuff As StringBuilder, _
                ByVal cchMaxColorChars As Integer, _
                ByVal pszSizeBuff As StringBuilder, _
                ByVal cchMaxSizeChars As Integer) As Integer
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sb As New StringBuilder(255)
        GetCurrentThemeName(Nothing, Nothing, sb, 255, Nothing, Nothing)
        MsgBox(sb.ToString)
    End Sub


    NormalColor = Blue
    HomeStead = Olive
    Mettalic = Silver

  • Bubba_WGU

    You'll have to use p/invoke to find out...  

    http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/functions/getthemecolor.asp frame=true

    In Windows Forms 2005, this will be offered via the VisualStyles api.


  • ubsman

    Mike,

    Thanks for the post, yeah I know that they user can customize their colors, the safest thing would be to determine what their system colors are and customize the control based on that. This gives me the start that I'm looking for though...

    Anthony

  • How to determine Windows XP Color Scheme