Background color in RGB

This is a discussion on Background color in RGB within the Windows Programming forums, part of the Platform Specific Boards category; I think I get the idea, JasonD. You delete your old brushes as soon as you set a new one, ...

  1. #16
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    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)?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #17
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    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.

Page 2 of 2 FirstFirst 12
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, 01:36 PM
  2. Writing Background RGB to file
    By SwiftOutlaw in forum Windows Programming
    Replies: 8
    Last Post: 03-27-2005, 05:56 AM
  3. Windows background color
    By Exile in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2005, 06:55 AM
  4. Stopwatch program (need help!)
    By modnar in forum C Programming
    Replies: 9
    Last Post: 03-21-2004, 11:42 PM
  5. Detect Close of a background process
    By Schwarzhelm in forum C Programming
    Replies: 1
    Last Post: 11-05-2003, 12:46 AM

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