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



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Editions 6.0

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.

REFERENCES

"ActiveX Controls: Subclassing a Windows Control" in the Visual C++ Programmer's Guide.

Modification Type:MajorLast Reviewed:10/17/2003
Keywords:kbCtrlCreate kbfix kbprb kbRichEdit KB230742