groupbox.
yellow, but a lot of space around them is simply gray (system color).
will fix it. This should be actually a quite simple thing for MFC to
do. But it looks it is not.
On Nov 2, 8:24 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
It is actually trivial, because a group box, like any other object drawn on a dialog, DOES
HAVE an "interior". By definition, anything inside its rectangle is the "interior".
The controls have to paint themselves, as all controls would. You would have to subclass
them and figure out how to set the color for the date-time picker. Note that the group
box does not draw the backgrounds; the controls draw their OWN backgrounds, and you would
have to inform each control in the group that it should draw itself with another color.
For CStatic is this trivial, you could even set it up to use the reflected =WM_CTLCOLOR
and return a yellow brush; for the date-time picker (a control I rarely use) I'm not sure
what you do.
To set this up you might do something like
void CMyDIalog::HighlightControls(CButton & groupbox, BOOL active)
{
CRect r;
groupbox.GetWindowRect(&r);
ScreenToClient(&r);
for(CWnd * wnd = GetWindow(GW_CHILD); wnd != NULL; wnd = wnd->GetWindow(GW_HWNDNEXT))
{ /* scan windows */
CRect w;
wnd->GetWindowRect(&w);
ScreenToClient(&w);
if(r.PtInRect(w.left, w.top))
wnd->SendMessage(UWM_SET_ACTIVE, (WPARAM)active);
} /* scan windows */
}
Now the user-defined message UWM_SET_ACTIVE is understood by the subclasses you have
written, and when received it changes the color based on the WPARAM value to either the
"active" or "inactive" color. Note that because I use SendMessage I don't even care about
the nature of the window; if it can handle the message, it does what is appropriate and if
it can't, it doesn't. I prefer to use Registered Window Messages for this purpose. You
might use WM_APP but you should avoid WM_USER messages since many controls actually
already use those for their own purposes.
joe
On Fri, 02 Nov 2007 09:51:35 -0700, przemyslaw.sl...@gazeta.pl wrote:
Hello,
I have the following case - on a massive dialog I have a couple of
group boxes. Basically I am interested in only one of these. It has
got a few controls in it - 3 static texts plus 2 date/time pickers.
When one of the pickers reaches certain date I want everything on in
this group to have yellow background. It looks like this is very
difficult - a groupbox deas not have a interior. Therefore it is
impossible to paint the whole group of controls.
I was trying to first make a huge static text (without a caption) and
then place the control on it. But it looks like this deas not work -
window does not support overlapping controls.
Could someone suggest me a simple solution?
Thanks a lot for help
Pshemek
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm