古詩詞大全網 - 成語解釋 - VC中控件遮住CTalCtrl控件的問題

VC中控件遮住CTalCtrl控件的問題

妳試試這個方法吧

在初始化函數OnInitDialog()中加入:

BOOL CTestDlg::OnInitDialog()

{

CDialog::OnInitDialog();

CBitmap bmp;

bmp.LoadBitmap(IDB_BITMAP2);

m_brBk.CreatePatternBrush(&bmp);

bmp.DeleteObject();

return TRUE; // return TRUE unless you set the focus to a control

}

在打開類向導,找到WM_CTLCOLOR消息,重載得對應函數OnCtlColor(),添加如下:

HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{

HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if (pWnd == this)

{

return m_brBk;

}

return hbr;

}