如何去掉按鈕在輸入焦點切換時所產生的閃爍

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會用系統默認的一個白色畫刷將背景擦除一遍,導致你會看到閃爍


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