HBRUSH CcsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_BTN) { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } // TODO: Return a different brush if the default is not desired return hbr; }
将按钮控件的背景画刷选成NULL_BRUSH就可以了
默认情况下按钮在焦点切换时,windows会用系统默认的一个白色画刷将背景擦除一遍,导致你会看到闪烁