winapi - How to change the text color in a disabled edit box using MFC? -


I have a dialog in which the editing box is disabled, but text should be displayed in red rather than default gray. I tried the following:

  minus CMyEdit :: OnEnable (BOOL bEnable) {CEdit :: OnEnable (bEnable); If (banable) {m_BackGroundColor = kRGBWhite; } And {m_BackGroundColor = kRGBDefaultGray; } M_TextColor = kRGBRed; M_BackgroundBrush.DeleteObject (); M_BackgroundBrush.CreateSolidBrush (m_BackGroundColor); Invalid (); }  

But its still only text in gray is displayed but if I delete the base class call CEdit :: OnEnable (bEnable); Then the new text color takes effect I

Cheers ...

Edit: ( to edit my comment For ) Sorry, I forgot to mention it in my original post. Instead of handling ON_WM_CTLCOLOR (), ON_WM_CTLCOLOR_REFLECT () is operated. I do not understand that by removing the call to the base class, the color of the text changes which is specified, but it only changes to the default gray color.

MSDN: an edit control that is not readable or incompatible WM_CTLCOLOREDIT sends the message in its original window when the control is almost ready to be ready.

There is no way to change the background or text color of an inactive (or read-only) editing box, besides its sub-clinging, do more pictures yourself.


Comments