Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Possible to use OCX from within a DLL???

Possible to use OCX from within a DLL???

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcomquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DVryce
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • D DVryce

      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

      C Offline
      C Offline
      Carlos Antollini
      wrote on last edited by
      #2

      And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.

      D 2 Replies Last reply
      0
      • C Carlos Antollini

        And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.

        D Offline
        D Offline
        DVryce
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • C Carlos Antollini

          And with this in the initinstance? AfxEnableControlContainer(); Carlos Antollini.

          D Offline
          D Offline
          DVryce
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups