FIX: CWnd::SubclassDlgItem Returns FALSE for OLE ControlsLast reviewed: September 19, 1997Article ID: Q148703 |
4.00
WINDOWS
kbprg kbole kbcode kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSUsing CWnd::SubclassDlgItem to subclass an OLE Control returns FALSE, after failing on the check for m_pCtrlCont != NULL in line 301 of Winctrl1.cpp.
CAUSEThe MFC framework's implementation of CWnd::SubclassDlgItem checks and uses the CWnd::m_pCtrlCont member of the OLE control, instead of the control container, which is the parent of the control. The source code should use pParent->m_pCtrlCont in order to access the container.
RESOLUTIONAs a workaround, use CWnd::SubclassWindow instead of CWnd::SubclassDlgItem, which is illustrated in the sample code section in this article.
STATUSMicrosoft has confirmed this to be bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Visual C++, 32-bit Edition, version 4.1.
MORE INFORMATION
Steps to Help Reproduce Problem
Sample Code to Work Around ProblemBOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); // Try to Subclass the Grid control by calling SubclassWindow CWnd* pWnd = GetDlgItem(IDC_GRID1); m_gridctrl.SubclassWindow(pWnd->m_hWnd); return TRUE; // set focus to first control of the dialog // Exception: OCX Property Pages should return FALSE } |
Additional reference words: 4.00 ocx ole control
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |