CButton Text Color change
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
How can I change the colour of the text in a button @ run-time. I tried to override the onctlcolor method:- HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_BTN) { pDC->SetTextColor(RGB(255,0,0));//set red return (HBRUSH) m_Brush.GetSafeHandle(); }; return hbr; } m_Brush is a member brush & in OnInitDialog method, I create it with a solid brush. m_Brush.CreateSolidBrush(RGB(129,129,129)); Thanks Gerry.