Creating a dialog from a COM dll
-
I am trying to display a CDialog derived class froma dll using COM. The COM stuff is working. It seems that my dialog is failing to create its own m_hWnd:
void __stdcall CMattDlgCmpnt::HtmlMsgBox( HWND wndParent, BSTR strmsg ) { CWnd* pWnd = new CWnd(); pWnd = CWnd::FromHandle(wndParent); CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->DoModal(); }
Debugging yields the following: {CNormalDlg hWnd=0x00000000} I tried doing this as well:CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->Create(IDD_DIALOG1); wndNormalDlg->ShowWindow(SW_SHOW);
But then I get an nasty ASSERT here:#ifdef _DEBUG if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE)) { **ASSERT(FALSE); // invalid dialog template name** PostNcDestroy(); // cleanup if Create fails too soon return FALSE; }
Any ideas. Thanks. Matt (Padawan Learner) -
I am trying to display a CDialog derived class froma dll using COM. The COM stuff is working. It seems that my dialog is failing to create its own m_hWnd:
void __stdcall CMattDlgCmpnt::HtmlMsgBox( HWND wndParent, BSTR strmsg ) { CWnd* pWnd = new CWnd(); pWnd = CWnd::FromHandle(wndParent); CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->DoModal(); }
Debugging yields the following: {CNormalDlg hWnd=0x00000000} I tried doing this as well:CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->Create(IDD_DIALOG1); wndNormalDlg->ShowWindow(SW_SHOW);
But then I get an nasty ASSERT here:#ifdef _DEBUG if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE)) { **ASSERT(FALSE); // invalid dialog template name** PostNcDestroy(); // cleanup if Create fails too soon return FALSE; }
Any ideas. Thanks. Matt (Padawan Learner)Hahahaha, i pity you man, coz you just dont know where the problem is:-D. dont worry i have been there too. just add this line at the start of the CMattDlgCmpnt::HtmlMsgBox method. AFX_MANAGE_STATE(AfxGetStaticModuleState()) if this doesnt solve ur problem, ur then on ur own. basically MFC dialogs and COM are not a good mix. u should try to use WTL or win32 way of poping a dialog. The world is becoming small and so are the people.