CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2001
    Posts
    4

    change default windows colors

    hi everyone,
    what i want to do is to change the standard windows colors of windows and controls. e.g. any windows common control uses unchangeably the default grey colors.

    i already tried to figure out, how to achieve this. i tried the api-commands 'SetClassWord()' and 'SetClassLong()' with which i could change the cursor (value GCL_HCURSOR), but not the color (value GCL_HBRBACKGROUND).
    another way that should be possible is to overwrite the default Redraw-Message of the WNDPROC. however, i didn't get this to work neither.

    i highly apprechiate any help on this.


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: change default windows colors

    Take a look at GetSysColors and SetSyscolors APIs... here's a short example:


    private Declare Function SetSysColors Lib "user32" (byval nChanges as Long, lpSysColor as Long, lpColorValues as Long) as Long
    private Declare Function GetSysColor Lib "user32" (byval nIndex as Long) as Long
    Const COLOR_SCROLLBAR = 0 'The Scrollbar colour
    Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper
    Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window
    Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window
    Const COLOR_MENU = 4 'Menu
    Const COLOR_WINDOW = 5 'Windows background
    Const COLOR_WINDOWFRAME = 6 'Window frame
    Const COLOR_MENUTEXT = 7 'Window Text
    Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95)
    Const COLOR_CAPTIONTEXT = 9 'Text in window caption
    Const COLOR_ACTIVEBORDER = 10 'Border of active window
    Const COLOR_INACTIVEBORDER = 11 'Border of inactive window
    Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop
    Const COLOR_HIGHLIGHT = 13 'Selected item background
    Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item
    Const COLOR_BTNFACE = 15 'Button
    Const COLOR_BTNSHADOW = 16 '3D shading of button
    Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used.
    Const COLOR_BTNTEXT = 18 'Button text
    Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window
    Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button
    Const COLOR_2NDACTIVECAPTION = 27 'Win98 only: 2nd active window color
    Const COLOR_2NDINACTIVECAPTION = 28 'Win98 only: 2nd inactive window color
    private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    'get the caption's active color
    col& = GetSysColor(COLOR_ACTIVECAPTION)
    'Change the active caption's color to red
    t& = SetSysColors(1, COLOR_ACTIVECAPTION, RGB(255, 0, 0))
    MsgBox "The old title bar color was" + Str$(col&) + " and is now" + Str$(GetSysColor(COLOR_ACTIVECAPTION))
    End Sub





  3. #3
    Join Date
    Oct 2001
    Posts
    4

    Re: change default windows colors

    thanks so far,
    only problem is, that this changes the settings system-wide, but i need to change the settings only for specific windows.


  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: change default windows colors

    Is there some reason you can't just use the BackColor property?


  5. #5
    Join Date
    Oct 2001
    Posts
    4

    Re: change default windows colors

    well, most common windows activeX controls don't have this backcolor property. they just use the system-wide defined settings.


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