Quick way to generate C++ files from an IDL file
-
I have to create an ActiveX control from a huge .IDL file. I have no problem creating a class to control the control but there seems to be a lot of leg work in writing out the declaration, definition, dispatch enumeration and dispatch map when creating the control class. Apart from manually running through the properties and methods in the IDL file is there a way of automating this process instead? Thanks Tom It will always be the bane of the civilized as to what to do with the barbarian
-
I have to create an ActiveX control from a huge .IDL file. I have no problem creating a class to control the control but there seems to be a lot of leg work in writing out the declaration, definition, dispatch enumeration and dispatch map when creating the control class. Apart from manually running through the properties and methods in the IDL file is there a way of automating this process instead? Thanks Tom It will always be the bane of the civilized as to what to do with the barbarian
In VC6, once you'd built the IDL there was an 'implement interface' option. Can't remember exactly where, since I saw it demo-ed on a COM course once, and never used it myself, since I preferred to go through and do it by hand to help reinforce my memory :) Don't know if there's an equivalent in later VS though, as I wouldn't use it if there was ...
Steve S Developer for hire
-
I have to create an ActiveX control from a huge .IDL file. I have no problem creating a class to control the control but there seems to be a lot of leg work in writing out the declaration, definition, dispatch enumeration and dispatch map when creating the control class. Apart from manually running through the properties and methods in the IDL file is there a way of automating this process instead? Thanks Tom It will always be the bane of the civilized as to what to do with the barbarian
Ummm - use ATL? That'll do the IDispatch implementation for you if you ask it nicely, as well as loads of other interfaces - I just created an ATL Control class in VS2003 and it looks like it'll implement these interfaces for you:
IDispatch, IPersistStreamInit, IOleControl, IOleObject, IOleInPlaceActiveObject, IViewObjectEx, IOleInPlaceObjectWindowless, IPersistStorage, ISpecifyPropertyPages, IQuickActivate, IDataObject, IProvideClassInfo2
-
Ummm - use ATL? That'll do the IDispatch implementation for you if you ask it nicely, as well as loads of other interfaces - I just created an ATL Control class in VS2003 and it looks like it'll implement these interfaces for you:
IDispatch, IPersistStreamInit, IOleControl, IOleObject, IOleInPlaceActiveObject, IViewObjectEx, IOleInPlaceObjectWindowless, IPersistStorage, ISpecifyPropertyPages, IQuickActivate, IDataObject, IProvideClassInfo2
Thanks for the responses guys :) I agree with your do it your self attitude but this interface has literally hundreds of events, methods and properties and I start to go a bit nuts after a while of doing that much repetitive work. Unfortunately, I've failed at failed at finding any assistance from VC2005. so I've decided I'd rather write a parser myself than manually go through it all. Is there a document that lists the complete spec for IDL files? and would anyone be interested in me publishing the resulting app? Thanks again Tom It will always be the bane of the civilised as to what to do with the barbarian
-
Thanks for the responses guys :) I agree with your do it your self attitude but this interface has literally hundreds of events, methods and properties and I start to go a bit nuts after a while of doing that much repetitive work. Unfortunately, I've failed at failed at finding any assistance from VC2005. so I've decided I'd rather write a parser myself than manually go through it all. Is there a document that lists the complete spec for IDL files? and would anyone be interested in me publishing the resulting app? Thanks again Tom It will always be the bane of the civilised as to what to do with the barbarian
-
Would it be less work to use the type library instead of the IDL ?
Steve S Developer for hire
Hi Steve Hmmm... I'm not sure. The control has to have all the functionality of the old contol but certain of the methods, events and properties require modification. It also has to fit into alot of legacy JavaScript functions and I can only change the GUID which luckily I put into a resource file but modifying the JavaScript is out of the question. The reason I say this is that I am unaware of how to achieve this effect using a type library. A nifty alternative would be great but I haven't thought of one. Thanks tom
-
Thanks for the responses guys :) I agree with your do it your self attitude but this interface has literally hundreds of events, methods and properties and I start to go a bit nuts after a while of doing that much repetitive work. Unfortunately, I've failed at failed at finding any assistance from VC2005. so I've decided I'd rather write a parser myself than manually go through it all. Is there a document that lists the complete spec for IDL files? and would anyone be interested in me publishing the resulting app? Thanks again Tom It will always be the bane of the civilised as to what to do with the barbarian
OK - I think I've got an automated solution for you. Note - this was done with VS2003...
- Create an ATL DLL project.
- Add an 'ATL Control' class. Use some throwaway name for the control interface (because you *will* be throwing it away :)), but make sure the class names are ones you're happy with.
- Copy'n'paste your IDL interface into the new projects IDL file
- In the Class View, right click the ATL Control class and select Add->Implement Interface... The interface you want to implement should be in the dialog that appears. Select it and click Finish. This should create bare method definitions.
Note that I've not determined what happens to event definitions.
-
OK - I think I've got an automated solution for you. Note - this was done with VS2003...
- Create an ATL DLL project.
- Add an 'ATL Control' class. Use some throwaway name for the control interface (because you *will* be throwing it away :)), but make sure the class names are ones you're happy with.
- Copy'n'paste your IDL interface into the new projects IDL file
- In the Class View, right click the ATL Control class and select Add->Implement Interface... The interface you want to implement should be in the dialog that appears. Select it and click Finish. This should create bare method definitions.
Note that I've not determined what happens to event definitions.
-
OK - I think I've got an automated solution for you. Note - this was done with VS2003...
- Create an ATL DLL project.
- Add an 'ATL Control' class. Use some throwaway name for the control interface (because you *will* be throwing it away :)), but make sure the class names are ones you're happy with.
- Copy'n'paste your IDL interface into the new projects IDL file
- In the Class View, right click the ATL Control class and select Add->Implement Interface... The interface you want to implement should be in the dialog that appears. Select it and click Finish. This should create bare method definitions.
Note that I've not determined what happens to event definitions.