An activeX control on a simple MFC application works in VC++2008, but not in VC++ 2010
-
Thursday, May 03, 2012 5:09 PM
I had a simple dialog based MFC application. The dialog holds a crystal report viewer control. It works fine in VC++ 2008. After converted to VC++ 2010, it doesn't work anymore: DoModal() as shown below failed.
CCrystal_ReportDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();The error message is:
Program: ... File: f\dd\vctools\vc7libs\ship\altmfc\src\mfc\occcont.cpp Line:925.
Debugged into the codes, the error is from calling (in dlgcore.cpp)
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);VC++ 2010 doesn't work for this CrViewer and another ActiveX controls. They works fine in VC++ 2008.
Thanks for any possible helps.
All Replies
-
Friday, May 04, 2012 5:49 AM
Debug again and execute the line after CreateDialogIndirect that calls GetLastError (or just type “@err,hr” into Watch window. This will give an error code. Which code do you see?
-
Friday, May 04, 2012 4:39 PM
The mfc codes (dlgcore.cpp) that generate the error:
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, pParentWnd->GetSafeHwnd(), AfxDlgProc); #ifdef _DEBUG dwError = ::GetLastError(); #endif
GetLastError() returned 0.
w.z.
- Marked As Answer by PowerAnalytics Thursday, May 24, 2012 10:42 PM
- Unmarked As Answer by PowerAnalytics Thursday, May 24, 2012 10:42 PM
-
Friday, May 04, 2012 4:44 PM
The cause of the problem is due to the following activeX control template in the .rc file, for which VC++ 2010 gives error in DoModal(), while VC++ 2008 works fine.
IDD_CRYSTAL_REPORT_DIALOG DLGINIT BEGIN IDC_ACTIVEXREPORTVIEWER1, 0x376, 128, 0 0x0000, 0x0000, 0x0710, 0x0000, 0x6a8f, 0x0000, 0x5a05, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0xffff, 0x000b, 0xffff, 0x0008, 0x0000, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x000b, 0x0000, 0x000b, 0x0000, 0x000b, 0x0000, 0x000b, 0xffff, 0x0013, 0x0409, 0x0000, 0x000b, 0x0000, 0 ENDNo sure anything wrong of this control template which was generated from the rc editor.
w.z.
- Proposed As Answer by Helen ZhaoModerator Monday, May 07, 2012 8:51 AM
- Marked As Answer by Helen ZhaoModerator Thursday, May 10, 2012 6:58 AM
- Unmarked As Answer by PowerAnalytics Thursday, May 24, 2012 10:40 PM
- Unproposed As Answer by PowerAnalytics Thursday, May 24, 2012 10:41 PM
-
Wednesday, June 20, 2012 11:37 PM
Found the solution:
Under the Project Configuration Properties go to Linker -> Advanced and set the 'Data Execution Prevention' property to No.
From: http://stackoverflow.com/questions/2911932/crxir2-doesnt-work-with-vs2010-on-windows-7-nor-on-vista
w.z.
w.z.
- Marked As Answer by PowerAnalytics Wednesday, June 20, 2012 11:37 PM

