Results 1 to 11 of 11

Thread: Windows Theme!

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    35

    Question Windows Theme!

    Hi,
    I was wondering how can I determine what windows theme is in use by the user. For example: if blue theme, I want to display "Blue Theme" (or Olive, Silver or Classic).
    I know it's not important, but it's something that I want to find out.
    Thank you,
    Mc

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Theme!

    You need to use the uxtheme.dll theme APIs to determine if a theme is being used (Windows XP and newer only).

    IsThemeActive and GetCurrentThemeName.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    35

    Re: Windows Theme!

    can you assist with a sample please?
    thank you

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Theme!

    Sorry, IsThemeActive is only for a particular app and not globally for your windows session.

    I'll whip something up right now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Member
    Join Date
    Jun 2003
    Posts
    44

    Re: Windows Theme!

    what's the API declare method
    I love VB6

    < advertising links removed by moderator >

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Windows Theme!

    VB Code:
    1. Private Declare Function OpenThemeData Lib "uxtheme" ( _
    2.     ByVal hWnd As Long _
    3.     ByVal pszClassList As Long _
    4. ) As Long
    5. Private Declare Function CloseThemeData Lib "uxtheme" (ByVal hTheme As Long) As Long
    6. Private Declare Function GetCurrentThemeName Lib "uxtheme" ( _
    7.     ByVal lpszThemeName As Long, _
    8.     ByVal dwMaxNameChars As Long, _
    9.     ByVal lpszColorBuff As Long, _
    10.     ByVal cchMaxColorChars As Long, _
    11.     ByVal lpszSizeBuff As Long, _
    12.     ByVal cchMaxSizeChars As Long _
    13. ) As Long
    14.  
    15. Public Function IsXPThemed() As Boolean
    16.     Dim hTheme As Long
    17.     hTheme = OpenThemeData(0, StrPtr("ExplorerBar"))
    18.     If (hTheme) Then
    19.         CloseThemeData hTheme
    20.         IsXPThemed = True
    21.     End If
    22. End Function
    23.  
    24. Public Function XPThemeName() As String
    25.     If (IsXPThemed()) Then
    26.         XPThemeName = Space$(260)
    27.         GetCurrentThemeName 0, 0, StrPtr(XPThemeName), 260, 0, 0
    28.         XPThemeName = Trim$(XPThemeName)
    29.     Else
    30.         XPThemeName = "n/a"
    31.     End If
    32. End Function
    Last edited by penagate; Dec 26th, 2005 at 06:19 AM.

  7. #7
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Windows Theme!

    straightaway i can see some problems here. sorry pean, maybe i'm wrong but i think it can cause some problems here
    VB Code:
    1. Private Declare Function OpenThemeData Lib "uxtheme" (ByVal hWnd As Long) As Long
    2.  
    3. hTheme = OpenThemeData(0, StrPtr("ExplorerBar"))

    two parameters are passed to OpenThemeData which takes only one parameter.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Windows Theme!

    Bahaha, sorry, I forgot the second one

    VB Code:
    1. Private Declare Function OpenThemeData Lib "uxtheme" ( _
    2.     ByVal hWnd As Long, _
    3.     ByVal pszClassList As Long _
    4. ) As Long

  9. #9
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Windows Theme!

    there is still a problem here, it will always be "", null string
    VB Code:
    1. Public Function XPThemeName() As String
    2.     If (IsXPThemed()) Then
    3.         Dim buffer As String: buffer = Space$(260)
    4.         GetCurrentThemeName 0, 0, StrPtr(buffer), 260, 0, 0
    5.         XPThemeName = Trim$(XPThemeName) '<==XPThemeName is always nothing, make a guess
    6.     Else
    7.         XPThemeName = "n/a"
    8.     End If
    9. End Function

    i think it should be
    VB Code:
    1. Public Function XPThemeName() As String
    2.     If (IsXPThemed()) Then
    3.         Dim buffer As String: buffer = Space$(260)
    4.         GetCurrentThemeName 0, 0, StrPtr(buffer), 260, 0, 0
    5.         XPThemeName = Trim$(buffer)
    6.     Else
    7.         XPThemeName = "n/a"
    8.     End If
    9. End Function

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Windows Theme!

    Fixed

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Theme!

    I finished this last night but didnt have time to post it. This works and is not for a particular app theming either.

    http://www.vbforums.com/showthread.php?t=378272
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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