Link to home
Start Free TrialLog in
Avatar of bhoomi_2000
bhoomi_2000

asked on

Background Color of GroupBox

Hi
I have a group box and i want to sent the BackGround color of the Group box as white ,i tried to trap the WM_CTLCOLOR for it ,it doesn't work...is there any simple way to work it out..
Bhoomi
Avatar of inpras
inpras

U have to derive UR class and map WM_CTLCOLOR to it and UR group box varible should be of that class type
Are you trying to cange the background color of the interior of the group box?

..B ekiM
Avatar of bhoomi_2000

ASKER

Hi
Yeah i have my own derived Group Box,tried to MAP the WM_CTLCOLOR for it,but unfortunately , i don't get any messages of WM_CTLCOLOR for the derived Group box,and also in the Parent class...
Yeah I am trying to change the background color of the interior of the group box..
Group boxes don't draw their interiors (AFAIK) .. just the border.

How about you put a white rectangle (static) control inside it.

If i place a static control ,white rectangle ,it overshadows other controls and the other controls which i listed in the group box is invisible
If i place a static control ,white rectangle ,it overshadows other controls and the other controls which i listed in the group box is invisible
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mike: Doesn't a group box paint its interior with a hollow (or maybe null) brush?  If so (unless one is being pedantic), the group box effectively doesn't do anything to its interior (paints it with nothing).  That is the point I was trying to make.  Obviously I didn't succeed :-).

bhoomi: Whether or not the rectangle is under or over other control is a matter of dialog layout order.  You can easily control this yourself (Ctrl+D in resrouce/dialog editor).

Mike's suggestion seems to be the best.  Good idea Mike .. didn't think of deriving and doing the OnEraseBkgnd, although I've done similar things many times myself.

bhoomi: might also be worth your while looks at an MSJ article (May 1997 C/C++ Q & A) by Paul D'Lascia where he shows how to put a bitmap background on a dialog, and discusses all the ins and outs of how to make controls appear correctly over a non-standard background (which is what you'll need to do to make your white background look correct).

HI MIKE AND RON
I think Ron and mikes both of your suggestion has to be combined for effective solution.But mike the other best way is to derive a own CStatic class and trap WM_CTLCOLOR message and paint the static control with required brush.Instead of handling WM_ERASEBACKGROUND,your suggestion also is an good alternative.