Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote:
C++
HBRUSH CEstatisDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

	int id = pWnd->GetDlgCtrlID();

	if (id == IDC_EDIT4)
	{
		//pDC->SetTextColor(RGB(0, 0, 0));
		pDC->SetBkColor(RGB(255, 0, 0));

		if (!m_whitebrush)
			m_whitebrush = CreateSolidBrush(RGB(255, 0,0));

		hbr = m_whitebrush;
	}

	return hbr;
}
but it doesn't work , the color remains gray

What I have tried:

I searched in internet but I don't find
Posted
Updated 14-Nov-19 4:10am
v2
Comments
Richard MacCutchan 14-Nov-19 4:30am    
The code appears to be correct. Use your debugger to check that it is following the correct path.
Member 14594285 14-Nov-19 5:06am    
I used debug and it pass for it..I don't understand

 
Share this answer
 
Comments
Member 14594285 14-Nov-19 5:12am    
in that it used a derived class, but I want to know if I wrote fine
Member 14594285 14-Nov-19 6:06am    
I solved
Maciej Los 14-Nov-19 6:23am    
5ed!
CPallini 14-Nov-19 11:01am    
Thank you, Maciej!
See the remarks in WM_CTLCOLOR message (WindowsX.h) - Win32 apps | Microsoft Docs[^]. It seems you need to use a more specific message capture.
 
Share this answer
 
Comments
Maciej Los 14-Nov-19 6:23am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900