Home » Category » Microsoft Visual C & C++

Microsoft Visual C & C++: Create CDHtmlDialog in statically linked MFC DLL failed

205| Mon, 02 Jun 2008 12:13:00 GMT| anonymous| Comments (0)
Hi,
My project need use a exe(statically linked MFC) load a dll(staticall
linked MFC),
and create a CDHtmlDialog in the dll.

I add a CDHtmlDialog to the DLL, "class DHtmlDialogTest : publi
CDHtmlDialog"
and create dialog at DLL's export function,
"DHtmlDialogTest.Create(IDD_DHtmlDialogTest
CWnd::GetDesktopWindow());"

But when excute DHtmlDialogTest.Create(IDD_DHtmlDialogTest
CWnd::GetDesktopWindow());
then it'll enter "dlgdhtml.cpp"'s functio
"CDHtmlDialog::OnInitDialog()"
at following code inside "CDHtmlDialog::OnInitDialog()"

----
if (m_pBrowserApp == NULL)
{
// create the control window
m_wndBrowser.CreateControl(CLSID_WebBrowser, NULL,
WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
lpUnk = m_wndBrowser.GetControlUnknown();
if (FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (void**
&m_pBrowserApp)))
{
m_wndBrowser.DestroyWindow();
DestroyWindow();
return TRUE;
}
}
----

it will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (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
CDHtmlDialog.

2. If use a exe(dynamically link MFC) load a dll(Extension DLL us
MFC),
it have no problem,
it can do the same thing, create a CDHtmlDialog in the dll perfectly.

Maybe because I can't load the resource?
Because I trce the call stack, when enter afxwin2.inl excute followin
code:
CDialog::Create(ATL_MAKEINTRESOURCE(nIDTemplate), pParentWnd);

ATL_MAKEINTRESOURCE(nIDTemplate) return a bad ptr,

Or is there any thing I need to be careful when use a exe(staticall
linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll?

Thanks for your help

-
rocktilldi
----
Posted via http://www.codecomments.co
----

Keywords & Tags: create, cdhtmldialog, statically, linked, mfc, dll, failed, microsoft, visual c++, vc

URL: http://visual-c.itags.org/visual-c-c++/68634/
 
«« Prev - Next »» 0 helpful answers below.

Microsoft Visual C & C++ Hot Answers

Microsoft Visual C & C++ New questions

Microsoft Visual C & C++ Related Categories