Results 1 to 11 of 11

Thread: changing titlebar color

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    changing titlebar color

    anyone know how to make the titlebar and border black when active (focus) and inactive

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    As far as I know, this is controlled by the system settings, so you would have to change the way windows are displayed system-wide.
    ~seaweed

  3. #3
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    If it is possible I would not know how to do it either because it is set by the system. Although I am sur eone of these API freaks on this page know of a way because nothing's impossible.

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    You don't have to be an API "freak", just check out http://www.mentalis.org/apilist/SetSysColors.shtml

    Here's an example that works, unless you're using XP theme which doesn't allow changing title bar colors (put two command buttons on a form and run this code):
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SetSysColors Lib "user32" _
    4.     (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
    5. Private Declare Function GetSysColor Lib "user32" _
    6.     (ByVal nIndex As Long) As Long
    7.    
    8. Private Const COLOR_SCROLLBAR = 0               'The Scrollbar color
    9. Private Const COLOR_BACKGROUND = 1              'The Color of the background with no wallpaper
    10. Private Const COLOR_ACTIVECAPTION = 2           'Caption of Active Window
    11. Private Const COLOR_INACTIVECAPTION = 3         'Caption of Inactive window
    12. Private Const COLOR_MENU = 4                    'Menu
    13. Private Const COLOR_WINDOW = 5                  'Windows background
    14. Private Const COLOR_WINDOWFRAME = 6             'Window frame
    15. Private Const COLOR_MENUTEXT = 7                'Window Text
    16. Private Const COLOR_WINDOWTEXT = 8              '3D dark shadow (Win95)
    17. Private Const COLOR_CAPTIONTEXT = 9             'Text in window caption
    18. Private Const COLOR_ACTIVEBORDER = 10           'Border of active window
    19. Private Const COLOR_INACTIVEBORDER = 11         'Border of inactive window
    20. Private Const COLOR_APPWORKSPACE = 12           'Background of MDI desktop
    21. Private Const COLOR_HIGHLIGHT = 13              'Selected item background
    22. Private Const COLOR_HIGHLIGHTTEXT = 14          'Selected menu item
    23. Private Const COLOR_BTNFACE = 15                'Button
    24. Private Const COLOR_BTNSHADOW = 16              '3D shading of button
    25. Private Const COLOR_GRAYTEXT = 17               'Grey text, of zero if dithering is used.
    26. Private Const COLOR_BTNTEXT = 18                'Button text
    27. Private Const COLOR_INACTIVECAPTIONTEXT = 19    'Text of inactive window
    28. Private Const COLOR_BTNHIGHLIGHT = 20           '3D highlight of button
    29. Private Const COLOR_2NDACTIVECAPTION = 27       'Win98 only: 2nd active window color
    30. Private Const COLOR_2NDINACTIVECAPTION = 28     'Win98 only: 2nd inactive window color
    31.  
    32. Private OriginalActiveColor As Long             ' Holds original active title bar color
    33. Private OriginalInactiveColor As Long           ' Holds original inactive title bar color
    34.  
    35. Private Sub ResetColors()
    36.     ' Resets the original system colors
    37.     SetSysColors 1, COLOR_ACTIVECAPTION, OriginalActiveColor
    38.     SetSysColors 1, COLOR_INACTIVECAPTION, OriginalInactiveColor
    39. End Sub
    40.  
    41. Private Sub ChangeColors()
    42.     ' Change active title bar color to black
    43.     SetSysColors 1, COLOR_ACTIVECAPTION, RGB(0, 0, 0)
    44.     ' Change inactive title bar color to black
    45.     SetSysColors 1, COLOR_INACTIVECAPTION, RGB(0, 0, 0)
    46. End Sub
    47.  
    48. Private Sub Command1_Click()
    49.     ResetColors
    50. End Sub
    51.  
    52. Private Sub Command2_Click()
    53.     ChangeColors
    54. End Sub
    55.  
    56. Private Sub Form_Load()
    57.     Command1.Caption = "Reset Colors"
    58.     Command2.Caption = "Change Colors"
    59.     OriginalActiveColor = GetSysColor(COLOR_ACTIVECAPTION)
    60.     OriginalInactiveColor = GetSysColor(COLOR_INACTIVECAPTION)
    61. End Sub
    ~seaweed

  5. #5
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Right on, hey don't get me wrong about the "Freaks" crack, when I call someone some said name reffering to something they're awsome at doing I am simply complementing said person(s).

    Thanx a lot for the code too.




    ~~Edited to add~~

    So that changes just you apps colors right?
    Last edited by Spajeoly; Apr 8th, 2003 at 11:42 AM.

  6. #6
    Lively Member da_haCKEr's Avatar
    Join Date
    Oct 2002
    Location
    Paradise Isle of Sri Lanka
    Posts
    116
    .:JanuZ:.
    .:JanuZ:.XtremeSoft


  7. #7
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Originally posted by Spajeoly
    So that changes just you apps colors right?
    No, it changes the system colors for all windows. da_hacker's link above shows you how to change just your title bar (actually it replaces your title bar with a user control).
    ~seaweed

  8. #8
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Generally speaking - it's not a good idea to change someone's system settings. Personally I would dump any app that does this sort of things.
    McGenius

  9. #9
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    As would I.

  10. #10
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Originally posted by McGenius
    Generally speaking - it's not a good idea to change someone's system settings. Personally I would dump any app that does this sort of things.
    I couldn't agree with you more. Unless it also changed my homepage and desktop background without asking. Then I would love it!
    ~seaweed

  11. #11
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Ooo ooo ooo, don't forget about changing the registry to nonexistant!!!

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