Home > Software engineering >  Turn a MFC DLL program invocation dialog box problem
Turn a MFC DLL program invocation dialog box problem

Time:10-13

The following is a dialog interface function called
 void ShowDlg (void)//display dialog 
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
CtestDlg CDLG;//definition used to test the dialog
Int b=CDLG. DoModal ();//normal display dialog
Driver DLG.//dialog variables (Driver is my own definition dialog class name)
//AfxEnableControlContainer ();
Int a=0;
A=DLG. DoModal ();//dialog box does not display the
}

CtestDlg is my new test dialog 1, can display the
normalDriver, I formally to use dialog, one loaded OCX controls, cannot show
After debugging, I found the difference between the two is test dialog 1 in CDLG. DoModal will call DoDataExchange function (), and the load control dialog 2 won't call, it should also be the cause of the latter can not display properly, is this why?

CodePudding user response:

Your Dll call AfxOleInit (); Class yet? InitInstance function calls, such as the App AfxOleInit ();

CodePudding user response:

Checked the online, others said in the engineering of InitInstance () function to add AfxEnableControlContainer (), I had been added, but the execution of DLG. DoModal (); When melt

CodePudding user response:

reference 1st floor VisualEleven response:
your Dll call AfxOleInit (); Class yet? InitInstance function calls, such as the App AfxOleInit ();

Call, this is program automatically add, and I also added a AfxEnableControlContainer (), the following
 BOOL CMy840DApp: : InitInstance () 
{
CWinApp: : InitInstance ();
AfxOleInit ();
AfxEnableControlContainer ();

return TRUE;
}

CodePudding user response:

Any call CoInitialize ()?

CodePudding user response:

reference 4 floor VisualEleven response:
any call CoInitialize ()?
no
  • Related