15. Declare 2 variables in CColors.h to manage the colors:
…………………….
public:
COLORREF m_clrText;
COLORREF m_clrBkgnd;
CBrush m_brBkgnd;
16. Initiatize the var in the constructor of the CColors.cpp
CColors::CColors()
{
m_clrText = RGB(0, 0, 0);
m_clrBkgnd = RGB(255, 255, 255);
m_brBkgnd.CreateSolidBrush(m_clrBkgnd);
}
17.
18.
19.
20. HBRUSH CColors::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
pDC->SetTextColor(m_clrText);
pDC->SetBkColor(m_clrBkgnd);
// TODO: Return a non-NULL brush if the parent's handler
should not be called
return m_brBkgnd;
//return NULL;
}
21.
22.
23.
24.
25.
26.
27. void CCheckDlg::OnClickedCheck1()
{
// TODO: Add your control notification handler code here
if (IsDlgButtonChecked(IDC_CHECK1))
m_edit.m_clrText = RGB(255, 0, 0);
else
m_edit.m_clrText = RGB(0, 0, 0);
RedrawWindow();
}
28.
29.
30.
31.
32. void CCheckDlg::OnClickedCheck2()
{
// TODO: Add your control notification handler code here
if (IsDlgButtonChecked(IDC_CHECK2))
m_edit.m_clrBkgnd = RGB(0, 255, 0);
else
m_edit.m_clrBkgnd = RGB(255, 255, 255);
RedrawWindow();
}