Solved

Create CDHtmlDialog in statically linked MFC DLL failed

Posted on 2006-06-29
7
1,076 Views
Last Modified: 2013-11-25
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_DHtmlDialogTest , CWnd::GetDesktopWindow());"

But when excute DHtmlDialogTest .Create(IDD_DHtmlDialogTest , CWnd::GetDesktopWindow());
enter "dlgdhtml.cpp"'s function "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)))

Maybe because I can't load the resource?
Because I trce the call stack, when enter afxwin2.inl excute following code:
CDialog::Create(ATL_MAKEINTRESOURCE(nIDTemplate), pParentWnd);
ATL_MAKEINTRESOURCE(nIDTemplate) 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?
0
Comment
Question by:sunsa
  • 3
  • 2
7 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17010454
have you tried that by using CreateDialogIndirect() instead if CDialog::Create() ?

-MAHESH
0
 

Author Comment

by:sunsa
ID: 17015822
Can you give me some sample codes for this? Thanks,
0
 

Author Comment

by:sunsa
ID: 17015954
Further explain:

Origin problem 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 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.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:sunsa
ID: 17016502
Problem solved,
I add
::OleInitialize(NULL);

in InitInstance()
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17016593
ok you may also use AfxOleInit() in ur applications InitInstance() to initiaklise OLE / COM library

-MAHESH
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 17047235
Closed, 500 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 101
Problem to event 3 104
Having a different time zone on your task bar 3 71
how to split multiple lines delimiter : 8 111
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question