Re: How to change a color of a group of controls
"Joseph M. Newcomer" <newcomer@flounder.com> ha scritto nel messaggio
news:bc1ni31aorjqbt5h70t4tq9lb550hav9v1@4ax.com...
It is actually trivial,
[... several details cut...]
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 */
}
Joe: please compare your code with the following WinForm code:
<code>
//
// There are two buttons: button1 and button 2.
// Handle buttons' Click event,
// and change group-box color accordingly
//
private void button1_Click(object sender, EventArgs e)
{
groupBox1.BackColor = Color.AliceBlue;
}
private void button2_Click(object sender, EventArgs e)
{
groupBox1.BackColor = Color.DarkSeaGreen;
}
</code>
Frankly speaking, I think that .NET WinForm code is *actually trivial* :)
....Don't you agree?
It's just a property set:
groupBox.BackColor = <...the color...>;
I would very much like MFC to be upgraded to meet the level of programmer
friendliness and productivity of WinForm...
I belive it is very possible!
Giovanni