CDHTMLDialog in a dll fails after DoDataExchange

Posted on 2006-06-11
Last Modified: 2013-11-20
I have an mfc application that makes use of multiple dlls for various functions.  I have no problems if all I want to do is display a CDialog from one of these dlls but any attempt to display a CDHTMLDialog dialog results in a fail, it seems that the error happens within the DoDataExchange block.

I have calls to AFX_MANAGE_STATE and tried AfxEnableControlContainer but no go.  The error also happens if I try to host an activex control on a CDialog window.

Any ideas where I may be going wrong?

Question by:horrid
LVL 44

Expert Comment

Comment Utility
Put a breakpoint at the start of the DoDataExchange and see which line it fails at by single stepping.
LVL 22

Assisted Solution

mahesh1402 earned 50 total points
Comment Utility
try first by explicitly setting parent of your dialog.. you may use SetParent() for this




Author Comment

Comment Utility
AFX_MANAGE_STATE(AfxGetStaticModuleState()); << required to use any mfc component
// this code works to create and show a CDialog
      m_HelpUI = new CHelpUI; << standard CDialog
      m_HelpUI->Create( HOLDER,NULL );
// this code fails to create and show a CDHTMLDialog

      m_help = new HelpUIHTML;  <<CDHTMLDialog
      m_help->Create( HOLDER, NULL); << fails trying this
        m_help->ShowWindow(SW_SHOW );

The code fails calling this
      { return afxCurrentWinApp; }
It seems the call to AfxGetApp fails when called from CDHTMLDialog DoDataExchange.  I can call it without issue from my dlls main body.

When single stepping through DoDataExchange I places my breakpoint at the exit of the function
void HelpUIHTML::DoDataExchange(CDataExchange* pDX)
}<< breakpoint here.
It makes it to the breakpoint and stepping through gets me to the above error point.
Thanks for the help so far.  As it is I can work around the issue and just use a cdialog and onpaint but I would love to understand whats going on. I am self taught in c++ because I needed it for work, there are so many things I just don't understand yet.
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

LVL 22

Assisted Solution

mahesh1402 earned 50 total points
Comment Utility
I have not tried CDHTMLDialog but it seems that you need dialog template and DHTML resource. Also to catch events fired by HTML elements  you must add an entry to the dialog's DHTML event map like :


Have a look at following samples at codeproject about CDHTMLDialog:
This sample demonstrates using the new MFC7 CDHtmlDialog class. A dialog with a simple HTML page is created and displayed, and events from objects within that page are handled, and the HTML within the page modified dynamically to respond to these events. <=============================== 'The MFC CDHtmlDialog class'

Also have look :

Hope this helps

Accepted Solution

rocktilldie earned 75 total points
Comment Utility
Hey man,
try add following code in your ::OnInitDialog


Author Comment

Comment Utility
Thanks all.  I ended up working out another solution to my problem but I expect the :OleInitialize was missing.  With XAML on its way and MS pulling support for  Win98 and 2k I don't think I will ever have issues like this again.  XAML and WPF make life so much better.

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now