Solved

CDHTMLDialog in a dll fails after DoDataExchange

Posted on 2006-06-11
6
632 Views
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?

0
Comment
Question by:horrid
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 16883356
Put a breakpoint at the start of the DoDataExchange and see which line it fails at by single stepping.
0
 
LVL 22

Assisted Solution

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

e.g

wndDlg->SetParent(this);

-MAHESH
0
 

Author Comment

by:horrid
ID: 16890746
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 );
      m_HelpUI->ShowWindow(SW_SHOW);
      
// 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
_AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp()
      { 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)
{
      
      CDHtmlDialog::DoDataExchange(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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Assisted Solution

by:mahesh1402
mahesh1402 earned 50 total points
ID: 16891810
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 :

BEGIN_DHTML_EVENT_MAP(CDHTMLDialogDlg)
    DHTML_EVENT_ONCLICK(.....)
    DHTML_EVENT_ONCLICK(.....)
END_DHTML_EVENT_MAP()

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.

http://www.codeproject.com/dotnet/dhtmldialog.asp <=============================== 'The MFC CDHtmlDialog class'


Also have look : http://www.codeproject.com/miscctrl/luo31.asp

Hope this helps
-MAHESH
0
 

Accepted Solution

by:
rocktilldie earned 75 total points
ID: 17029219
Hey man,
try add following code in your ::OnInitDialog

AFX_MANAGE_STATE(AfxGetStaticModuleState());
::OleInitialize(NULL);
AfxEnableControlContainer();
0
 

Author Comment

by:horrid
ID: 17039455
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 90
iSeries DB2 Query 2 91
centeredAverage challenge 8 131
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 104
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

13 Experts available now in Live!

Get 1:1 Help Now