Set Controls Red, Green Yellow

Lets suppose I have three button controls, which I'll toggle from "red, yellow and green'
At first I'll set them all red

-- Lets suppose I switch on IDC_X
I'll set IDC_X to Green, keep all the others (IDC_Y and IDC_Z) red.
-- Switch on IDC_Y
Set IDC_Y to Green, keep IDC_X Green and IDC_Z Red (IDC_Z hasnt changed yet)
-- Switch on IDC_X again
Set IDC_X, to Yellow. Keep IDC_Y Green, and IDC_Z red.

and so on.

Trying to figure out how to modify OnDrawItem to do this.

------------------

for (int i=0; i<3; i++)
m_cmd[i] = FALSE;
m_cmd[m_szCmd] = TRUE;

InvalidateRect(0,FALSE);
}

void CBusDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT di)
{
CRect re(di->rcItem);
CBrush red(RGB(255,0,0));
CBrush green(RGB(0,255,0));
int i=-1;

switch(nIDCtl)
{
case IDC_X: i = 0; break;
case IDC_Y: i = 1; break;
case IDC_Z: i = 2; break;

}
if(i >= 0) FillRect(di->hDC,re,m_cmd[i] ? green : red);
DrawEdge(di->hDC,re,EDGE_SUNKEN,BF_RECT);
CDialog::OnDrawItem(nIDCtl,di);
}
[1191 byte] By [mop] at [2007-11-17 22:40:11]