您的位置:首页 > 编程语言 > C语言/C++

Change the Foreground and Background Colour of Staic Text Control in VC++

2006-10-18 23:09 916 查看
overrider OnCtlColor for WM_CTLCOLOR for your dialog like following to set background and text color :

e.g.

HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if(pWnd->m_hWnd== GetDlgItem(IDC_TEXT)->m_hWnd) //Use static ID of your static text control
{
pDC->SetBkColor( RGB( 255, 0, 0 ) ); //red background
pDC->SetTextColor( RGB( 255, 255, 255 ) ); //white text
return hbr;
}

return hbr;
}

Otherwise derive your own control....like following
http://www.codeproject.com/staticctrl/coloredit_colorstatic.asp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐