The information in this article applies to:
SYMPTOMSWhen you create an ActiveX control dynamically via CWnd::CreateControl(), your window's message-handlers in the CWnd-derived class will not be called. For example, if you create a handler for WM_KILLFOCUS [OnKillFocus()] in the CWnd-derived class of a Microsoft Masked Edit control, it will not be called. CAUSECWnd::CreateControl() doesn't subclass the HWND associated with the control. RESOLUTIONFor message-handlers to be called, the CWnd-derived class needs to subclass the HWND. You can do this by calling SubclassDlgItem(). Calling SubclassDlgItem() right after CreateControl() will cause an assert because CreateControl() previously called CWnd::Attach(). SubclassDlgItem() will call Attach() again. To avoid this assert, we need to call Detach() first before calling SubclassDlgItem() as follows:
STATUSThis behavior is by design. MORE INFORMATIONTo set up a message handler for WM_KILLFOCUS in the CWnd-derived class of Microsoft Masked Edit control, you'll need to add the following lines to the header file:
The following lines go in the .CPP file:
When you insert an ActiveX control via Component Gallery, the Visual C++
wrapper class has Create() functions that end up calling
CWnd::CreateControl().
Additional query words: ocx
Keywords : kbole kbMFC kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 |
Last Reviewed: August 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |