Vc如何改变对话框中控件文字的颜色和背景色
作者:cnfgg 日期:2009-06-25
复制内容到剪贴板
程序代码
程序代码HBRUSH CMyDialog::OnCtlColor(CDC* pDC,CWnd* pWnd,UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO:Change any attributes of the DC here
m_brush.DeleteObject();
m_brush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE));
if (pWnd->GetDlgCtrlID()<=IDC_AXIS8&&pWnd->GetDlgCtrlID()>=IDC_AXIS0
||pWnd->GetDlgCtrlID()>=IDC_AXISY5&&pWnd->GetDlgCtrlID()<=IDC_AXISY0)
{
hbr = (HBRUSH)( m_brush.GetSafeHandle()); // Passing a Handle to the Brush
pDC->SetBkColor(::GetSysColor(COLOR_3DFACE));
// Setting the Color of the Text Background to the one passed by the Dialog
SetTextColor(pDC->GetSafeHdc(),m_pColorSetting->GetColorAxis());
// Setting the Text Color to the one Passed by the Dialog
}
// Return a different brush if the default is not desired
return hbr;
}
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO:Change any attributes of the DC here
m_brush.DeleteObject();
m_brush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE));
if (pWnd->GetDlgCtrlID()<=IDC_AXIS8&&pWnd->GetDlgCtrlID()>=IDC_AXIS0
||pWnd->GetDlgCtrlID()>=IDC_AXISY5&&pWnd->GetDlgCtrlID()<=IDC_AXISY0)
{
hbr = (HBRUSH)( m_brush.GetSafeHandle()); // Passing a Handle to the Brush
pDC->SetBkColor(::GetSysColor(COLOR_3DFACE));
// Setting the Color of the Text Background to the one passed by the Dialog
SetTextColor(pDC->GetSafeHdc(),m_pColorSetting->GetColorAxis());
// Setting the Text Color to the one Passed by the Dialog
}
// Return a different brush if the default is not desired
return hbr;
}
[本日志由 cnfgg 于 2009-08-24 03:40 PM 编辑]
文章来自: 本站原创
Tags: vc 对话框 界面 消息映射 mfc
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇
