Article ID: 146617 - Last Review: November 21, 2006 - Revision: 2.1 FIX: SetWindowText(NULL) Doesn't Clear .OCX Edit ControlThis article was previously published under Q146617 SYMPTOMS
It is possible to use AppWizard to create an OLE Custom Control (.ocx file)
that subclasses a standard Windows control. If you choose to subclass an
edit control, the control will not exhibit the same behavior as a standard
edit control. Specifically, in the case where the control is not initialized with data, the user types some text into the control, and then SetWindowText(NULL) is called to clear the text, the text in the control will not be cleared. If this same sequence of events were to occur in a standard edit control, the contents of the edit control would be cleared. CAUSE
COleControl handles the WM_SETTEXT message in its OnSetText handler. The
first few lines of this function are:
RESOLUTION
To work around this problem, override OnSetText() in the COleControl
derived class, and copy the code from COleControl::OnSetText() into the
overridden funtion, with the following change:
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem was corrected in Visual C++
32-bit Edition, version 4.2.
APPLIES TO
| Article Translations
|

Back to the top
