I'm trying migrate a VC++ 6 based code to work with VS2015 CLR. I have major functionality working, but UI has some things missing.
I have traced this issue to failures of SubclassDlgItem due to NULL HWnd for parent CWnd. It is NULL, because Create on a CDialog derived parent class returns 0 at following in dlgcore.cpp
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
::DestroyWindow(hWnd);
hWnd = NULL;
}
m_nFlags = 256 (Defined as #define WF_OLECTLCONTAINER 0x0100 // some descendant is an OLE control in afxwin.h)
And hWnd is not NULL, but '::CreateDialogIndirect() did NOT create the window (ie. due to error in template) and returns NULL' as per Microsoft comments
Following is the code for parent CWnd
CreateEx(
WS_EX_NOPARENTNOTIFY,
NULL,
"MainClient",
WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, // Locate at upper left corner of client area
1, 1, // Initial size doesn't matter - will be sized to fit parent
parent->GetSafeHwnd(),
NULL
);
Following is the code for CDialog creation
m_pMainDialog = new CxMainDialog();
m_pMainDialog->Create(IDD_MAIN_DIALOG, this);
Below is the CxMainDialog constructor
CxMainDialog::CxMainDialog(CWnd* pParent /*=NULL*/)
: CDialog(CxMainDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CxMainDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
How may I get this to work?
VERIFY
macro:VERIFY(CreateEx(...)
). – Werner Henze