public:
CBrush m_MeaningBrush; //背景顔色畫刷
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
CSkinDlg::CSkinDlg(CWnd* pParent )
: CDialog(CSkinDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
//建立為紅色背景
m_MeaningBrush.CreateSolidBrush(RGB(255,0,0));
}
//修改文本框背景顔色
HBRUSH CSkinDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (pWnd->GetDlgCtrlID() == IDC_EDIT1) //編輯框的名稱ID
{
pDC->SetTextColor(RGB(255,255,255)); //編輯框類的字型設定為白色;
pDC->SetBkMode(TRANSPARENT); //設定為透明不影響字型顔色
return (HBRUSH)m_MeaningBrush.GetSafeHandle(); //傳回目前編輯框的背景畫刷
}
if (pWnd->GetDlgCtrlID() ==IDC_STATIC1) //編輯框的名稱ID
{
pDC->SetTextColor(RGB(255,255,255)); //編輯框類的字型設定為白色;
pDC->SetBkMode(TRANSPARENT); //設定為透明不影響字型顔色
return (HBRUSH)m_MeaningBrush.GetSafeHandle(); //傳回目前編輯框的背景畫刷
}
// TODO: Return a different brush if the default is not desired
return hbr;
}