Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WM_CTRLCOLOR

WM_CTRLCOLOR

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alton Williams
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • A Alton Williams

      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

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Have you set a reflection mapping up (ON_WM_CTLCOLOR_REFLECT) in the class's message map? Steve S

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups