Results 1 to 10 of 10

Thread: how to get Windows title bar color set in system

  1. #1

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225

    how to get Windows title bar color set in system

    how i can color of window's title bar which is set in system in Desktop settings .. I ve tried with Getsyscolors but in that i couldnt find parameter value for Active Title Bar . Any one know abt this parameter or how to get window's Title bar color wheter its using 1 color or combination of 2 colors ....
    Chander
    Email:chander@myrealbox.com

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    you mean this

    VB Code:
    1. Private Sub Form_Load()
    2.     Me.BackColor = vbActiveTitleBar
    3. End Sub
    ?
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    will it give me the color of global window's title bar color i meant what is set in Active Title bar color in Desktop settings ???
    Chander
    Email:chander@myrealbox.com

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Play around with this
    VB Code:
    1. Private Declare Function SetSysColors Lib "user32" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
    2. Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    3. Const COLOR_SCROLLBAR = 0 'The Scrollbar colour
    4. Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper
    5. Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window
    6. Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window
    7. Const COLOR_MENU = 4 'Menu
    8. Const COLOR_WINDOW = 5 'Windows background
    9. Const COLOR_WINDOWFRAME = 6 'Window frame
    10. Const COLOR_MENUTEXT = 7 'Window Text
    11. Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95)
    12. Const COLOR_CAPTIONTEXT = 9 'Text in window caption
    13. Const COLOR_ACTIVEBORDER = 10 'Border of active window
    14. Const COLOR_INACTIVEBORDER = 11 'Border of inactive window
    15. Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop
    16. Const COLOR_HIGHLIGHT = 13 'Selected item background
    17. Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item
    18. Const COLOR_BTNFACE = 15 'Button
    19. Const COLOR_BTNSHADOW = 16 '3D shading of button
    20. Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used.
    21. Const COLOR_BTNTEXT = 18 'Button text
    22. Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window
    23. Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button
    24. Const COLOR_2NDACTIVECAPTION = 27 'Win98 only: 2nd active window color
    25. Const COLOR_2NDINACTIVECAPTION = 28 'Win98 only: 2nd inactive window color
    26. Private Sub Form_Load()
    27.     'KPD-Team 1998
    28.     'URL: [url]http://www.allapi.net/[/url]
    29.     'E-Mail: [email]KPDTeam@Allapi.net[/email]
    30.     'Get the caption's active color
    31.     col& = GetSysColor(COLOR_ACTIVECAPTION)
    32.     'Change the active caption's color to red
    33.     t& = SetSysColors(1, COLOR_ACTIVECAPTION, RGB(255, 0, 0))
    34.     MsgBox "The old title bar color was" + Str$(col&) + " and is now" + Str$(GetSysColor(COLOR_ACTIVECAPTION))
    35. End Sub

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    If you are drawing your own title bars you should use the DrawFrameCaption API call to draw the various bits...

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  6. #6

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    no i m not making my own frame .. well i think i was looking for COLOR_ACTIVECAPTION constant .. I saw this example fm All Api but didnt get this constant .. well i m going to try this ...
    Chander
    Email:chander@myrealbox.com

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    The C declaration (from WinUser.h) is:

    Code:
    #define COLOR_SCROLLBAR         0
    #define COLOR_BACKGROUND        1
    #define COLOR_ACTIVECAPTION     2
    #define COLOR_INACTIVECAPTION   3
    #define COLOR_MENU              4
    #define COLOR_WINDOW            5
    #define COLOR_WINDOWFRAME       6
    #define COLOR_MENUTEXT          7
    #define COLOR_WINDOWTEXT        8
    #define COLOR_CAPTIONTEXT       9
    #define COLOR_ACTIVEBORDER      10
    #define COLOR_INACTIVEBORDER    11
    #define COLOR_APPWORKSPACE      12
    #define COLOR_HIGHLIGHT         13
    #define COLOR_HIGHLIGHTTEXT     14
    #define COLOR_BTNFACE           15
    #define COLOR_BTNSHADOW         16
    #define COLOR_GRAYTEXT          17
    #define COLOR_BTNTEXT           18
    #define COLOR_INACTIVECAPTIONTEXT 19
    #define COLOR_BTNHIGHLIGHT      20
    
    #if(WINVER >= 0x0400)
    #define COLOR_3DDKSHADOW        21
    #define COLOR_3DLIGHT           22
    #define COLOR_INFOTEXT          23
    #define COLOR_INFOBK            24
    #endif /* WINVER >= 0x0400 */
    
    #if(WINVER >= 0x0500)
    #define COLOR_HOTLIGHT                  26
    #define COLOR_GRADIENTACTIVECAPTION     27
    #define COLOR_GRADIENTINACTIVECAPTION   28
    #endif /* WINVER >= 0x0500 */
    
    #if(WINVER >= 0x0400)
    #define COLOR_DESKTOP           COLOR_BACKGROUND
    #define COLOR_3DFACE            COLOR_BTNFACE
    #define COLOR_3DSHADOW          COLOR_BTNSHADOW
    #define COLOR_3DHIGHLIGHT       COLOR_BTNHIGHLIGHT
    #define COLOR_3DHILIGHT         COLOR_BTNHIGHLIGHT
    #define COLOR_BTNHILIGHT        COLOR_BTNHIGHLIGHT
    #endif /* WINVER >= 0x0400 */
    so the VB declaration is:
    VB Code:
    1. Private Enum ColourConstatntIndexes
    2.     COLOR_SCROLLBAR = 0
    3.     COLOR_BACKGROUND = 1
    4.     COLOR_ACTIVECAPTION = 2
    5.     COLOR_INACTIVECAPTION = 3
    6.     COLOR_MENU = 4
    7.     COLOR_WINDOW = 5
    8.     COLOR_WINDOWFRAME = 6
    9.     COLOR_MENUTEXT = 7
    10.     COLOR_WINDOWTEXT = 8
    11.     COLOR_CAPTIONTEXT = 9
    12.     COLOR_ACTIVEBORDER = 10
    13.     COLOR_INACTIVEBORDER = 11
    14.     COLOR_APPWORKSPACE = 12
    15.     COLOR_HIGHLIGHT = 13
    16.     COLOR_HIGHLIGHTTEXT = 14
    17.     COLOR_BTNFACE = 15
    18.     COLOR_BTNSHADOW = 16
    19.     COLOR_GRAYTEXT = 17
    20.     COLOR_BTNTEXT = 18
    21.     COLOR_INACTIVECAPTIONTEXT = 19
    22.     COLOR_BTNHIGHLIGHT = 20
    23.     COLOR_3DDKSHADOW = 21
    24.     COLOR_3DLIGHT = 22
    25.     COLOR_INFOTEXT = 23
    26.     COLOR_INFOBK = 24
    27.     COLOR_HOTLIGHT = 26
    28.     COLOR_GRADIENTACTIVECAPTION = 27
    29.     COLOR_GRADIENTINACTIVECAPTION = 28
    30. End Enum

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8
    Addicted Member
    Join Date
    Feb 2004
    Posts
    145

    Re: how to get Windows title bar color set in system

    Does this method (eg: COLOR_ACTIVECAPTION) or (vbActiveTitlebar) work consistently for Win10? it seems that an application that i have that works fine on Win7 and WinXP doesn't work accurately on win10 (doesn't show correct color)? Using color = vbActiveTitlebar doesn't seem to show correct color in Win10?
    Last edited by Jimboat; Jan 10th, 2021 at 05:05 PM.
    /Jimboat

  9. #9
    Addicted Member
    Join Date
    Feb 2004
    Posts
    145

    Re: how to get Windows title bar color set in system

    it seems that using GetSysColor doesn't always identify the proper color. For example, if the user has a theme installed that they are using then this does not get the colors that the theme uses, it only gets what the system settings are set to. Is there a way around this?
    /Jimboat

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: how to get Windows title bar color set in system

    Quote Originally Posted by Jimboat View Post
    it seems that using GetSysColor doesn't always identify the proper color. For example, if the user has a theme installed that they are using then this does not get the colors that the theme uses, it only gets what the system settings are set to. Is there a way around this?
    1st. Recommend starting your own thread. This one is nearly 20 years old.
    2nd. If the window is using a theme, you'll likely want to look at the uxtheme.dll API/functions (XP+)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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