Thread: how to set the background colour of a static box?

  1. #1
    Geek. Cobras2's Avatar
    Join Date
    Mar 2002
    Location
    near Westlock, and hour north of Edmonton, Alberta, Canada
    Posts
    113

    how to set the background colour of a static box?

    Hey it's me Cobras2, I'm back again and this timei've gotten into Windows coding. anyway heres my theory:

    i want to have a window.
    inside the window is two static boxes, one takes the top half of the window's client area, and displays a bitmap.
    the other takes the bottom half of the client area and displays text.
    however, the bitmap may or may not be smaller then half the client area; so i put in transparency. however, the static box on top, where the bitmap is transparent, is the colour of a window background.
    the static box on the bottom, is coloured like a 3d object.


    what i am trying to do is set the background colour of the static box, to the windows colour for 3d controls

    alternatively, how could i change the background colour of (the bottom) static box that is displaying text, to the default colour for 'window' ?

    both static boxes were created using CreateWindowEx, with the STATIC window class, and later have the text and images added to them. (in WM_PAINT and WM_SIZE messages)
    James G. Flewelling
    Rgistered Linux User #327359
    Athabasca University Student (BSc. CIS)

    http://catb.org/~esr/faqs/smart-questions.html
    http://catb.org/jargon/

    http://www.ebb.org/ungeek
    ---GEEK CODE---
    Version: 3.12
    GCS/IT/M d- s+:++ a-->->>+>++>+++>? C++++>$ UL++>++++$ P++>++++ L++>++++$
    E W++ N o? K? w++(--)>--- O? M? V? PS--(---) PE Y+ PGP? t 5? !X R(*)>++
    tv-->! b++(+++)>++++ DI? D+++(---)>++++$ G e*>++$ h++>*$ r!>+++ y?
    ----/GEEK CODE----
    upd: 2005-02-11

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Handle the WM_CTLCOLORSTATIC msg and return from it the handle of a brush to be used to colour the control background. GetSysColor will return the required system colour:

    HBRUSH hbr=CreateSolidBrush(GetSysColor(COLOR_BTNFACE));

    Remeber to DeleteObject on the brush handle when you are done with it.

  3. #3
    Geek. Cobras2's Avatar
    Join Date
    Mar 2002
    Location
    near Westlock, and hour north of Edmonton, Alberta, Canada
    Posts
    113
    thanx!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking errors with static var
    By Elysia in forum C++ Programming
    Replies: 8
    Last Post: 10-27-2007, 05:24 PM
  2. Replies: 3
    Last Post: 12-24-2006, 10:11 AM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM