class CControlColorDlg : public CDialog
{
// Construction
public:
CControlColorDlg(CWnd* pParent = NULL); // standard constructor
CBrush m_brush;
// Dialog Data
//{{AFX_DATA(CControlColorDlg)
enum { IDD = IDD_CONTROLCOLOR_DIALOG };
CEdit m_ctrlEdit;
//}}AFX_DATA
..
// Generated message map functions
//{{AFX_MSG(CControlColorDlg)
,,
afx_msg HCURSOR OnQueryDragIcon();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CControlColorDlg::CControlColorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CControlColorDlg::IDD, pParent)
{
..
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_brush.CreateSolidBrush(RGB(255, 0, 0));
}
..
BEGIN_MESSAGE_MAP(CControlColorDlg, CDialog)
//{{AFX_MSG_MAP(CControlColorDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
..
HBRUSH CControlColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if(m_ctrlEdit.m_hWnd == pWnd->m_hWnd)
{
pDC->SetTextColor(RGB(0, 0, 255));
pDC->SetBkColor(RGB(255, 255, 0));
return m_brush;
}
if(nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(0, 255, 0));
pDC->SetBkMode(TRANSPARENT);
return m_brush;
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
Flat controls with "mouseover" and "mouseout" effects.