WM_CTRLCOLOR
-
Hi, I've subclassed a an edit control from CEdit. below is what's in the header file:
class CMyEdit: public CEdit { public: void ChangeColour(const unsigned long &bg, const unsigned long &fg); // Generated message map functions protected: //{{AFX_MSG(CEditEx) afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: CBrush m_brush; unsigned long TextColour; unsigned long BKColour; CFont m_TextFont; }; }
the methods in my C++ files are:HBRUSH CMyEdit::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CEdit::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetTextColor(TextColour); // TODO: Return a different brush if the default is not desired return m_brush; }
void CMyEdit::ChangeColour(const unsigned long &fg, const unsigned long &bg) { TextColour = fg; BKColour = bg; m_brush.DeleteObject(); m_brush.CreateSolidBrush(BKColour); Invalidate();
My problem is why the method OnCtlColor is NOT being called? Any explanations Thanks, Alton -
Hi, I've subclassed a an edit control from CEdit. below is what's in the header file:
class CMyEdit: public CEdit { public: void ChangeColour(const unsigned long &bg, const unsigned long &fg); // Generated message map functions protected: //{{AFX_MSG(CEditEx) afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: CBrush m_brush; unsigned long TextColour; unsigned long BKColour; CFont m_TextFont; }; }
the methods in my C++ files are:HBRUSH CMyEdit::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CEdit::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetTextColor(TextColour); // TODO: Return a different brush if the default is not desired return m_brush; }
void CMyEdit::ChangeColour(const unsigned long &fg, const unsigned long &bg) { TextColour = fg; BKColour = bg; m_brush.DeleteObject(); m_brush.CreateSolidBrush(BKColour); Invalidate();
My problem is why the method OnCtlColor is NOT being called? Any explanations Thanks, Alton