如何去掉按钮在输入焦点切换时所产生的闪烁

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会用系统默认的一个白色画刷将背景擦除一遍,导致你会看到闪烁


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章