views:

144

answers:

2

I am developing an OCX with some DISP_FUNCTION_ID defined. How could I automatically generate a wrapper for it to be used in an MFC C++ Dialog so it can be autoregenerated when I add functions to my OCX?

Regards

+1  A: 

Use dual interfaces instead. Write their declaration in IDL so you can create a type library with midl.exe. Which you can then #import into the client app, that automatically generates a wrapper based on the _com_ptr_t class. Dual interfaces are automatically generated when you use the ATL Object wizard.

Hans Passant
How can I generate the IDL file from the OCX?
zitronic
I see visual studio does it automatically, thanks
zitronic
A: 

I used ClassWizard to generate the class from a type library.

To do this, open ClassWizard, and press "Add Class", selecting "From a type library" from the drop down list. Locate your type library, and then select all the classes from the list it presents to you.

Each of the classes is derived from COleDispatchDriver. You can use the CreateDispatch() method of the class to create an instance of the class.

Source

zitronic