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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ActiveX components in Regular DLLs

ActiveX components in Regular DLLs

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomdebuggingc++design
3 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.
  • S Offline
    S Offline
    Sid Price
    wrote on last edited by
    #1

    Hello, I have an application that I need to use some ActiveX components with. First let me describe the structure of the application and then the problem we are having. The application being developed is an add-on or extension for use with third party applications. It is contained in a regular MFC DLL so that it can provide the required "C" type calls for the host application. Because it also has some user interface components it uses a dialog based MFC structure to privide these. We used a regular DLL rather than an extension DLL because the the "host" applications could be written in any language and with any framework, it is an unknown factor outside of our control. However, we did want to use MFC internally. The CWinApp instance in the DLL starts a modal dialog which acts as kind of toolbar for the product. In the OnInitDialog method of this dialog we create several other modeless dialogs for status and data display. Now to the problem. If we place an ActiveX component onto any of the dialogs we get assertions and dialogs fail to create. As a example if the ActiveX components are placed on the main dialog the debug trace view shows the following text: CoCreateInstance of OLE control {50548E24-4550-11D4-A9A7-00400516A5AD} failed. >>> Result code: 0x800401f0 >>> Is the control is properly registered? Warning: CreateDlgControls failed during dialog init. The error is CO_E_FIRST, Moniker enumeration failure. Whatever that means. So, could someone please give us a few pointers here. The InitInstance method of the CWinAp instance in teh DLL has a call to AfxEnableControlContainer. what more is required. The component loads into the test conatiner just fine. It is also visible and appears correctly in the dialog editor. Any help or pointers much appreciated, Thanks Sid

    B 1 Reply Last reply
    0
    • S Sid Price

      Hello, I have an application that I need to use some ActiveX components with. First let me describe the structure of the application and then the problem we are having. The application being developed is an add-on or extension for use with third party applications. It is contained in a regular MFC DLL so that it can provide the required "C" type calls for the host application. Because it also has some user interface components it uses a dialog based MFC structure to privide these. We used a regular DLL rather than an extension DLL because the the "host" applications could be written in any language and with any framework, it is an unknown factor outside of our control. However, we did want to use MFC internally. The CWinApp instance in the DLL starts a modal dialog which acts as kind of toolbar for the product. In the OnInitDialog method of this dialog we create several other modeless dialogs for status and data display. Now to the problem. If we place an ActiveX component onto any of the dialogs we get assertions and dialogs fail to create. As a example if the ActiveX components are placed on the main dialog the debug trace view shows the following text: CoCreateInstance of OLE control {50548E24-4550-11D4-A9A7-00400516A5AD} failed. >>> Result code: 0x800401f0 >>> Is the control is properly registered? Warning: CreateDlgControls failed during dialog init. The error is CO_E_FIRST, Moniker enumeration failure. Whatever that means. So, could someone please give us a few pointers here. The InitInstance method of the CWinAp instance in teh DLL has a call to AfxEnableControlContainer. what more is required. The component loads into the test conatiner just fine. It is also visible and appears correctly in the dialog editor. Any help or pointers much appreciated, Thanks Sid

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      I am thinking that maybe the OLE or COM Initialization has not occurred. Isn't there usually a call like AfxOleInit() at the beginning of a MFC program? But maybe you are not getting that in your DLL. Seems to me that you might need to call CoInitialize() because the hosting program might not necessarily have done that, and your DLL is always running in some thread of that parent process, which means it does not necessarily have an initialization of OLE or COM going for it be default.

      S 1 Reply Last reply
      0
      • B Blake Miller

        I am thinking that maybe the OLE or COM Initialization has not occurred. Isn't there usually a call like AfxOleInit() at the beginning of a MFC program? But maybe you are not getting that in your DLL. Seems to me that you might need to call CoInitialize() because the hosting program might not necessarily have done that, and your DLL is always running in some thread of that parent process, which means it does not necessarily have an initialization of OLE or COM going for it be default.

        S Offline
        S Offline
        Sid Price
        wrote on last edited by
        #3

        Thanks for the response. I think you are correct about the AfxOleInit call. What I have discovered is that the CWinApp object in my DLL is being created before the CWinApp object in the host application so the Ole init is not done when the dialog in the DLL tries to load the ActiveX component. This has led me to have to rethink the startup of the DLL code because the host application may or may not initialize OLE. I think I need to delay the creation on my DLL based CWinApp object until the host is up and running fully. This is possible, a call already exists for the host to make for that. What may be more difficult is having the DLL know whether OLE is initialized or not so that if the answer is not it can do it. Does this approach sound reasonable? Do you know if there is an API call that would tell the DLL if OLE init had been done? Many thanks for taking the time to respond, Sid

        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