-1

I am attempting to migrate a Visual C++ 6.0 program (originally written on a Windows NT machine) to Visual C++ 2010 for use on my 64-bit Windows 7 PC. The program compiles fine but there is a runtime assertion failure which yeilds the following output in the debugger:

CoCreateInstance of OLE control {F9043C85-F6F2-101A-A3C9-08002B2F49FB} failed.

Result code: 0x80040154

Is the control is properly registered?

Warning: Resource items and Win32 Z-order lists are out of sync. Tab order may be not defined well.

Warning: CreateDlgControls failed during dialog init.

The failed assertion is on line 925 of occcont.cpp:

ASSERT(IsWindow(pTemp->m_hWnd));

I understand from http://dynamicsuser.net/forums/p/25968/140697.aspx that the Microsoft Common Dialog Control v6.0 might not be registered. I registered it with Regsrv32.exe and restarted windows but the error persists.

My goal is to tell whether this old program can work with new tools--not to actually rewrite the old program (though that will come later). Is it possible to make the old program run on my newer machine?

EDIT: Addition of the code which causes the assertion failure

BOOL CCameraSimulationApp::InitInstance()
{
    AfxEnableControlContainer();

#ifdef _AFXDLL
    Enable3dControls();         // Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic();   // Call this when linking to MFC statically
#endif

    INITCOMMONCONTROLSEX InitCtrlEx;
    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;

  if (!InitCommonControlsEx(&InitCtrlEx))
  {
      printf("Common Controls failed to initialize");//debug
  }

    CCameraSimulationDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();

...

umphish
  • 75
  • 1
  • 9
  • 1
    No downvote from me, but it would be nice if you could locate and paste the code that ends up causing the assertion failure, otherwise the question is too hard to answer. Also, are you calling this : http://msdn.microsoft.com/en-us/library/windows/desktop/bb775697(v=vs.85).aspx ? – SirDarius Jan 07 '15 at 15:35
  • @SirDarius `CDialog::DoModal()` causes the assertion. I have tried your suggestion and the function returns true, which leads me to believe the issue is not actually with the ActiveX Control, but rather with my own code. – umphish Jan 07 '15 at 18:38
  • um ... just a sidenote : this has nothing to do with ActiveX. At all. – specializt Jan 07 '15 at 18:44

1 Answers1

1
  • 0x80040154 is REGDB_E_CLASSNOTREG. That means that the class has not been registered.
  • {F9043C85-F6F2-101A-A3C9-08002B2F49FB} is the Commom Dialog Control.

So, it seems that that control is not registered. You attempted to register it but I'd guess that you registered the 64 bit version. You are likely compiling a 32 bit program and so need to register the 32 bit version.

regsvr32 C:\Windows\SysWOW64\ComDlg32.ocx

Make sure you do this whilst elevated. That said, I would expect the control to be registered out of the box.

Finally, it's 2015 now and you should not be using this control anymore. Try to wean yourself onto something more modern.

I'd also comment that there's no need for you to re-compile the program. To start with I'd concentrate on getting your existing executable to work on the new machine.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I was actually trying run a 64-bit program because it is dependent on some matlab dlls that are also 64-bit. Regardless, I have tried registering `C:\Windows\SysWOW64\ComDlg32.ocx` and `C:\Windows\System32\ComDlg32.ocx` while elevated but I still see the same assertion. I would like to rewrite the control completely but that is unfortunately out of the scope of what I am allowed to do here. Also, the old executable works fine on the new machine. – umphish Jan 07 '15 at 16:15
  • If the old executable works fine then the control is presumably registered. In which case it would appear that the issue must lie in your code and how you are compiling it. Details of which are absent. – David Heffernan Jan 07 '15 at 16:17
  • It seems the assertion failure is caused by the `CDialog::DoModal()` function call. Is that of any use or are there other details I should provide that may help describe the situation? I apologize for my shortcommings here--this is my first time working with a C++ GUI program. – umphish Jan 07 '15 at 16:26
  • Why don't you do some debugging. If you are really just starting out with GUI programming then you've got a steep learning curve. You first of all need to understand what your program does. – David Heffernan Jan 07 '15 at 16:28