Microsoft KB Archive/230742

= PRB: Text Does Not Appear when an ActiveX Control Is Based on Rich Edit 2.0 =

Article ID: 230742

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Foundation Class Library 4.2, when used with:
 * Microsoft Visual C++ 6.0 Service Pack 5

-



This article was previously published under Q230742



SYMPTOMS
Text does not appear when an ActiveX control is based on Rich Edit 2.0.



CAUSE
The RichEdit20 window proc does not do anything in WM_ERASEBKGND except return the value "1", indicating it has erased the background. The WM_PAINT message handler is supposed to take care of erasing the background. However, the WM_PAINT message handler does not do anything because the update rect is (0,0,0,0).



RESOLUTION
The solution is to invalidate the Rich Edit control's window, and then pass the WM_PAINT message to the windows procedure of the Rich Edit 2.0 control. For example: void CMyRichEditOCX::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) {   Invalidate(FALSE); // DC passed by WM_PAINT is ignored ::CallWindowProc(*m_pfnSuper, m_hWnd, WM_PAINT, (WPARAM)0, (LPARAM)0); }



STATUS
This behavior is by design.



MORE INFORMATION
The MFC CRichEditCtrl class was designed to support the Rich Edit 1.0 control and does not support the Rich Edit 2.0 control.

In order to use Rich Edit 2.0 in an MFC application, call LoadLibrary to load the Riched20.dll and access its functionality through the Win32 API.

