sunsa
asked on
Create CDHtmlDialog in statically linked MFC DLL failed
Hi,
My project need use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll.
I add a CDHtmlDialog to the DLL, "class DHtmlDialogTest : public CDHtmlDialog"
and create dialog at DLL's export function,
"DHtmlDialogTest .Create(IDD_DHtmlDialogTes t , CWnd::GetDesktopWindow()); "
But when excute DHtmlDialogTest .Create(IDD_DHtmlDialogTes t , CWnd::GetDesktopWindow());
enter "dlgdhtml.cpp"'s function "CDHtmlDialog::OnInitDialo g()"
at following code inside "CDHtmlDialog::OnInitDialo g()"
if (m_pBrowserApp == NULL)
{
// create the control window
m_wndBrowser.CreateControl (CLSID_Web Browser, NULL,
WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
lpUnk = m_wndBrowser.GetControlUnk nown();
if (FAILED(lpUnk->QueryInterf ace(IID_IW ebBrowser2 , (void**) &m_pBrowserApp)))
{
m_wndBrowser.DestroyWindow ();
DestroyWindow();
return TRUE;
}
}
it will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterf ace(IID_IW ebBrowser2 , (void**) &m_pBrowserApp)))
Maybe because I can't load the resource?
Because I trce the call stack, when enter afxwin2.inl excute following code:
CDialog::Create(ATL_MAKEIN TRESOURCE( nIDTemplat e), pParentWnd);
ATL_MAKEINTRESOURCE(nIDTem plate) return a bad ptr,
But I can create a CDialog in the same DLL, only can't create a CDHtmlDialog,
Or is there any thing I need to aware when use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll?
My project need use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll.
I add a CDHtmlDialog to the DLL, "class DHtmlDialogTest : public CDHtmlDialog"
and create dialog at DLL's export function,
"DHtmlDialogTest .Create(IDD_DHtmlDialogTes
But when excute DHtmlDialogTest .Create(IDD_DHtmlDialogTes
enter "dlgdhtml.cpp"'s function "CDHtmlDialog::OnInitDialo
at following code inside "CDHtmlDialog::OnInitDialo
if (m_pBrowserApp == NULL)
{
// create the control window
m_wndBrowser.CreateControl
WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
lpUnk = m_wndBrowser.GetControlUnk
if (FAILED(lpUnk->QueryInterf
{
m_wndBrowser.DestroyWindow
DestroyWindow();
return TRUE;
}
}
it will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterf
Maybe because I can't load the resource?
Because I trce the call stack, when enter afxwin2.inl excute following code:
CDialog::Create(ATL_MAKEIN
ATL_MAKEINTRESOURCE(nIDTem
But I can create a CDialog in the same DLL, only can't create a CDHtmlDialog,
Or is there any thing I need to aware when use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll?
ASKER
Can you give me some sample codes for this? Thanks,
ASKER
Further explain:
Origin problem will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterf ace(IID_IW ebBrowser2 , (void**) &m_pBrowserApp)))
the m_wndBrowser is NULL and lpUnk is also NULL.
and:
1. I can create a CDialog in the same DLL above, only can't create a CDHtmlDialog.
2. If use a exe(dynamically link MFC) load a dll(Extension DLL use MFC),
it can do the same thing create a CDHtmlDialog in the dll fine.
Thanks.
Origin problem will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterf
the m_wndBrowser is NULL and lpUnk is also NULL.
and:
1. I can create a CDialog in the same DLL above, only can't create a CDHtmlDialog.
2. If use a exe(dynamically link MFC) load a dll(Extension DLL use MFC),
it can do the same thing create a CDHtmlDialog in the dll fine.
Thanks.
ASKER
Problem solved,
I add
::OleInitialize(NULL);
in InitInstance()
I add
::OleInitialize(NULL);
in InitInstance()
ok you may also use AfxOleInit() in ur applications InitInstance() to initiaklise OLE / COM library
-MAHESH
-MAHESH
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-MAHESH