MFC程式設計學習之改變對話方塊和控制元件及文字顏色
阿新 • • 發佈:2018-12-10
//程式訊息流:首先對話方塊繪製時,會發送WM_CTLCOLOR訊息,那麼OnCtlColor()函式
//將響應該訊息,程式將用該函式返回的畫刷對控制元件進行繪製。
HBRUSH CSettingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
if(pWnd->GetDlgCtrlID()==IDC_LINE_STYLE)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
return m_brush_YL;
}
//CString DlgCtrlID;
//DlgCtrlID.Format("Value:%d",pWnd->GetDlgCtrlID());
//MessageBox(DlgCtrlID);
if(pWnd->GetDlgCtrlID()==IDC_DLG_SETTING)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
return m_brush_YL;
}
return hbr;
//將響應該訊息,程式將用該函式返回的畫刷對控制元件進行繪製。
HBRUSH CSettingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
if(pWnd->GetDlgCtrlID()==IDC_LINE_STYLE)
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
return m_brush_YL;
}
//CString DlgCtrlID;
//DlgCtrlID.Format("Value:%d",pWnd->GetDlgCtrlID());
//MessageBox(DlgCtrlID);
if(pWnd->GetDlgCtrlID()==IDC_DLG_SETTING)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
}
return hbr;
}