The text is missing when an ActiveX control is based on Rich Edit 2.0 (810302)
The information in this article applies to:
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code
model that is provided by the Microsoft .NET Framework and the unmanaged
native Microsoft Windows code model. SYMPTOMSWhen you create an ActiveX control in Visual C++ .NET using
Rich Edit 2.0, the text does not appear.CAUSEThe Rich Edit 2.0 window procedure does not do anything in
WM_ERASEBKGND except return the value "1", which indicates that the Rich Edit
2.0 window procedure has erased the background. The WM_PAINT message handler is
supposed to erase the background. However, the WM_PAINT message handler does
not do anything because the update rect is (0,0,0,0). RESOLUTIONTo resolve this problem, you must invalidate the control
window of Rich Edit 2.0, and then pass the WM_PAINT message to the windows
procedure of the Rich Edit 2.0 control. To do this, add the WM_PAINT event
handler. You must append the following code (to the existing code) for the
WM_PAINT event handler:
// MyTestControlCtrl.h
class CMyTestControlCtrl : public COleControl
{
DECLARE_DYNCREATE(CMyTestControlCtrl)
protected:
afx_msg void OnPaint();
...
}
// MyTestControlCtrl.cpp
BEGIN_MESSAGE_MAP(CMyTestControlCtrl, COleControl)
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
ON_WM_PAINT()
END_MESSAGE_MAP()
void CMyTestControlCtrl::OnPaint()
{
Invalidate(FALSE);
::CallWindowProc(*m_pfnSuper, m_hWnd, WM_PAINT, (WPARAM)0, (LPARAM)0);
// Do not call COleControl::OnPaint() for painting messages
} Compile the code and run application. Custom control displays text in ActiveX Control Test Container. STATUS This
behavior is by design.REFERENCESFor additional information, see the following topic in the
Visual C++ Programmer's Guide:
Modification Type: | Major | Last Reviewed: | 1/5/2006 |
---|
Keywords: | kbRichEdit kbCtrlCreate kbprb KB810302 kbAudDeveloper kbAudITPRO |
---|
|