Ole
May 19th, 1999, 08:06 PM
I want to change the color of the font in an readonly editview ,but I don't know how.I know I can set the font in InitialUpdate()function of the Editview.
But I do not know how to set the color of the Font in the readonly editview,
Please hlp me if you can. Thank you!
Jason Teagle
May 20th, 1999, 02:38 AM
If this was an edit control, the following should work:
Add a handler for the WM_CTL_COLOR message to the parent of the edit control. In the code it generates, put the following:
---HBRUSH CMyDlgOrWnd::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hBrBkgnd = NULL ;
UINT uID ;
uID = pWnd->GetDlgCtrlID();
if (nCtlColor == CTLCOLOR_EDIT && uID == IDC_MY_EDIT_CONTROL)
{
pDC->SetBkColor(desired back colour);
pDC->SetTextColor(desired text colour);
hBrBkgnd = ::GetSysColorBrush(COLOR_WINDOW or whatever);
// Note - if you create a custom brush for the background, the brush
// MUST remain in existence outside of this routine - so make it a
// member of this class.
}
// We must ONLY call the base class if this call was not for our edit
// control - otherwise it will override our settings.
if (hBrBkgnd == NULL)
hBrBkgnd = CBaseClass::OnCtlColor(pDC, pWnd, nCtlColor);
return hBrBkgnd ;
}
---
I don't know if this works for an edit control embedded in an edit view; you would have to check the edit view's code for the ID of the embedded edit control.
Does this help? If not, I'll have a little fiddle to see if I can sort it.