Thread: Background color in RGB

  1. #16
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    I think I get the idea, JasonD. You delete your old brushes as soon as you set a new one, and then delete the final brush in WM_DESTROY. But what if you have a number of brushes that you would like to switch between during your program? Would I be right in saying that they should not be deleted, with a globally scoped reference system (for retrieval purposes)?
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ

  2. #17 JasonD's Avatar
    Join Date
    Mar 2003
    If you have a number of specific brushes that you will be switching to during the run of the program, you can create them in WM_CREATE and destroy them in WM_DESTROY, and use the SetWindowLong() during the program to change the window's background brush to be any of them.

    The code I showed you is a method of changing the background brush to any RGB value whatsoever during the run of your program, when you have no idea what color brushes you will need. It is based off a 'color picker' program that Charles Petzold wrote, and it is a very nice way of handling that situation.

    But, generally, I think you get the basic idea - don't destroy a brush that is still currently being used, and destroy brushes right away if you are not going to be using them again. If you have brushes that will definitely be used throughout the program, you can create/destroy them at start up/shut down.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Pixel addition
    By Hunter2 in forum Game Programming
    Replies: 4
    Last Post: 12-15-2008, 02:36 PM
  2. Writing Background RGB to file
    By SwiftOutlaw in forum Windows Programming
    Replies: 8
    Last Post: 03-27-2005, 06:56 AM
  3. Windows background color
    By Exile in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2005, 07:55 AM
  4. Stopwatch program (need help!)
    By modnar in forum C Programming
    Replies: 9
    Last Post: 03-22-2004, 12:42 AM
  5. Detect Close of a background process
    By Schwarzhelm in forum C Programming
    Replies: 1
    Last Post: 11-05-2003, 01:46 AM