0

I have an ActiveX control in MSVC++10 which compiles into a .ocx. I have added another "ATL Simple Object" to this control, from which I want to export some functions.

If this library is called OcxTest, I have to perform the following steps to export a function:

  1. Declare the function as protected member of the class COcxTestCtrl (as generated by the Project Wizard) in the file OcxTestCtrl.h.

  2. Define the function in OcxTestCtrl.cpp.

  3. Add it to the Dispatch Map in OcxTestCtrl.cpp:

    BEGIN_DISPATCH_MAP(COcxTestCtrl, COleControl)
         DISP_FUNCTION_ID(COcxTestCtrl, "Test", 1, Test, VT_I4, VTS_I4 VTS_I4)
    END_DISPATCH_MAP()
  4. Add it to the IDL in OcxTest.idl at the following point:

    [ uuid(...), version(1.0),  control ]
        library OcxTestLib {
        importlib(STDOLE_TLB);
        [ uuid(...) ]
        dispinterface _DOcxTest {
            properties:
            methods:
                [id(1)] int Test(int x, int y);
    };

Now, I'm a bit lost as to where I define the exports for the other "ATL Simple Object" that I added to the project. I guess the first two steps are analogous to what I wrote. What about the other two steps?

  1. Is the definition of the Dispatch Map completely analogous to that of the main object?

  2. Where in the IDL do I have to put the exported function?

Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
  • 1
    You are getting yourself into trouble by trying to do this by hand. Functions are not exported in COM servers. Use the wizards to get everything right. Right-click the interface in the class view window, Add, Add Method. You probably need to start over again to avoid the hand-typed code causing misery. – Hans Passant May 17 '13 at 15:59
  • Ok, thanks for pointing out the wizard. (Indeed it will freeze every time because I might have changed the IDL too much, but I was able to use it on a fresh project to see what it does. My question is therefore answered.) – Felix Dombek May 17 '13 at 17:10

0 Answers0