Changing the background color

This is a discussion on Changing the background color within the Windows Programming forums, part of the Platform Specific Boards category; I know i can set the background color of my program when I compile using hbrBackground but how can i ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Location
    Phoenix, Arizona
    Posts
    26

    Changing the background color

    I know i can set the background color of my program when I compile using hbrBackground

    but how can i change the color while the programe is running.

    Thanks.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    One of many ways is to handle the WM_ERASEBKGND message.

    gg

  3. #3
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    To change the background color of your window you could use the SetClassLong function with the GCL_HBRBACKGROUND parameter like so:

    Code:
    DeleteObject((HBRUSH)SetClassLong(hwnd, GCL_HBRBACKGROUND, 
                                                             (LONG)CreateSolidBrush
                                                              (RGB (color1,
                                                                        color2,
                                                                        color3 )
                                                               )));
    happy coding!

  4. #4
    Registered User
    Join Date
    Jul 2004
    Location
    Phoenix, Arizona
    Posts
    26
    Thanks both of you.I used andyhunter's and it worked fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. Changing background color of irregular image
    By Tesita in forum C++ Programming
    Replies: 5
    Last Post: 11-03-2003, 07:17 PM
  3. Changing a windows background color
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 04-21-2002, 11:51 AM
  4. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

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