Possible to use OCX from within a DLL???
-
I have a very particular problem that I need some help with. My problem is that I am creating a regular MFC DLL that displays a dialog which then does some work based on user input. I need to create an ActiveX control (in this case Snowbound Software's Rastermaster OCX) on this dialog at runtime. No matter how I've tried to approach this problem it just does not seem to want to work. It seems to bomb in the InitControlContainer() function in the MFC source file OCCCONT.CPP, where it goes to make the call to m_pCtrlCont = afxOccManager->CreateContainer(this); I've tried this using other ActiveX controls and have gotten the same problem so I do not believe it's a problem with the snowbound control in particular. Can anyone please tell me if I'm just doing something wrong, or if what I'm attempting to do is just simply not possible? Any help will be GREATLY appreciated! Thanks! :confused: X 10
-
I have a very particular problem that I need some help with. My problem is that I am creating a regular MFC DLL that displays a dialog which then does some work based on user input. I need to create an ActiveX control (in this case Snowbound Software's Rastermaster OCX) on this dialog at runtime. No matter how I've tried to approach this problem it just does not seem to want to work. It seems to bomb in the InitControlContainer() function in the MFC source file OCCCONT.CPP, where it goes to make the call to m_pCtrlCont = afxOccManager->CreateContainer(this); I've tried this using other ActiveX controls and have gotten the same problem so I do not believe it's a problem with the snowbound control in particular. Can anyone please tell me if I'm just doing something wrong, or if what I'm attempting to do is just simply not possible? Any help will be GREATLY appreciated! Thanks! :confused: X 10
And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.
-
And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.
I am making sure to call AfxOleInit() and AfxEnableControlContainer() in my App's InitInstance. Then in the constructor for my dialog I create a new object of the ActiveX control type which I then call the Create() member on in the dialog's OnInitDialog() function. For some reason after the call to create the control object's HWND is still NULL. It keeps failing on an assertion error in "Winocc.cpp" which I think is a result of trying to call a method on this object with a NULL hwnd. The error as reported by the VC++ debug window is as follows: Loaded 'C:\WINNT\system32\OLE32.DLL', no matching symbolic information found. CoCreateInstance of OLE control {B2D168E0-5597-101D-843A-DA16297B4C87} failed. >>> Result code: 0x800401f0 >>> Is the control is properly registered? I'm pretty sure the control is registered however as I ran a successful call to regsvr32 on it.
-
And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.
Just solved my own problem... The answer was to be found in some comments containing the code for the AfxOleInit() call. I had to calle OLEInitialize() before doing anything else in my app's InitInstance() and now it all works fine. Why calling AfxOleInit() doesn't have the same affect is beyond me, but hey, that's just the way it works! :-D