通过编辑框的值,使编辑框的值超出某个范围时具有告警背景色

 

HBRUSH CDlg1Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(pWnd->GetDlgCtrlID() == IDC_EDIT1) { COLORREF bkColor = GetSysColor(COLOR_WINDOW); if( GetDlgItemInt(IDC_EDIT1) > 1000) bkColor = RGB(255, 0, 0); CRect rcRect; pWnd->GetClientRect( &rcRect ); pDC->FillSolidRect(rcRect, bkColor); pDC->SetBkColor(bkColor); hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } // TODO: Return a different brush if the default is not desired return hbr; }

你可能感兴趣的:(null,attributes)