Setting the background color of my main window

This is a discussion on Setting the background color of my main window within the Windows Programming forums, part of the Platform Specific Boards category; I'm having difficulty setting it to an "opportune" color. How can I set it to the "default" of the user ...

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Setting the background color of my main window

    I'm having difficulty setting it to an "opportune" color. How can I set it to the "default" of the user at the time? For instance, on my WinXP system I have the silver setting on it so the normal background color against the LTGRAY color looks terrible! Hmmm...I guess I'm looking to set the background color to the color of the menu. Is that possible? Thanks!
    1978 Silver Anniversary Corvette

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    i think these might help

    DWORD GetSysColor(
    int nIndex // display element
    );

    BOOL WINAPI SetSysColors(
    int cElements, // number of elements to change
    CONST INT *lpaElements, // address of array of elements
    CONST COLORREF *lpaRgbValues // address of array of RGB values
    );

    though i doubt you want to set the whols system colors, you might get some idea from this exerpt from the WNDCLASS struct

    hbrBackground
    Handle to the class background brush. This member can be a handle to the physical brush to be used for painting the background, or it can be a color value. A color value must be one of the following standard system colors (the value 1 must be added to the chosen color). If a color value is given, you must convert it to one of the following HBRUSH types:

    COLOR_ACTIVEBORDER
    COLOR_ACTIVECAPTION
    COLOR_APPWORKSPACE
    COLOR_BACKGROUND
    COLOR_BTNFACE
    COLOR_BTNSHADOW
    COLOR_BTNTEXT
    COLOR_CAPTIONTEXT
    COLOR_GRAYTEXT
    COLOR_HIGHLIGHT
    COLOR_HIGHLIGHTTEXT
    COLOR_INACTIVEBORDER
    COLOR_INACTIVECAPTION
    COLOR_MENU
    COLOR_MENUTEXT
    COLOR_SCROLLBAR
    COLOR_WINDOW
    COLOR_WINDOWFRAME
    COLOR_WINDOWTEXT

    The system automatically deletes class background brushes when the class is freed. An application should not delete these brushes, because a class may be used by multiple instances of an application.

    When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint function.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    So what you are saying to do is something like:
    Code:
    wndclass.hbrBackground = COLOR_MENU;
    to set the classes background to the color of the menu, for instance? Is that what I would do? Thanks...
    1978 Silver Anniversary Corvette

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    i didn't realize this till to late but,
    actually its unfortunate by XP actually doesn't use the system colors when your in skin mode... so i have no clue as to how you would get the skin color...

    so you stuck with

    wc.hbrBackground = CreateSolidBrush(RGB(rrr, ggg, bbb));

    the Menu color is a gradient from 244,244,238 to 224,226,235 the last number varies slightly up and down the height of its draw area.

    i recommend playing around with the last one...

    ::edit:: unfortunatly this isn't an excellent solution since the user may not be using the silver skin...
    Last edited by no-one; 07-06-2002 at 09:27 PM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #5
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Hmmm...maybe I should just make the background white or something neutral...
    1978 Silver Anniversary Corvette

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    i always go:

    wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09:23 AM
  3. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  4. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 06:55 PM
  5. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 08:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21