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会用系统默认的一个白色画刷将背景擦除一遍,导致你会看到闪烁
本文详细解读了HBRUSHCcsDlg类中的OnCtlColor函数,着重讨论了如何通过该函数自定义按钮控件的背景颜色和画刷,特别关注了在焦点切换时避免闪烁效果的方法。
5561

被折叠的 条评论
为什么被折叠?



