点击切换按钮,实现编辑框底色的改变

prjDlg.h中定义:

CBrush m_bluebrush,m_pinkbrush;

COLORREF  bluecolor,pinkcolor;


.cpp的初始化文件中定义:

bluecolor = RGB(0,255,255);

pinkcolor = RGB(249,204,226);

m_bluebrush.CreateSolidBrush(bluecolor);//bluecolor

m_pinkbrush.CreateSolidBrush(pinkcolor); //pinkcolor


OnCtlColor中:

switch (pWnd->GetDlgCtrlID())//对某一个特定控件进行判断

{     

case IDC_WD1_XL: case IDC_WD1_JJ: case IDC_JIY_XL: case IDC_JIY_JJ: 

pDC->SetBkColor(bluecolor);     

hbr = (HBRUSH) m_bluebrush; 

break; 

case IDC_JINGY_XL: case IDC_JINGY_JJ: case IDC_WD2_DY: case IDC_WD2_XL: case IDC_WD2_JJ: 

pDC->SetBkColor(pinkcolor);     

hbr = (HBRUSH) m_pinkbrush; 

break; 

你可能感兴趣的:(点击切换按钮,实现编辑框底色的改变)