Hi,
I have an existing .ocx file which contains a map. I need to open this file in C++ and not in MFC. MSDN help suggested me that it can be done throuch " #import "file_name" " However, the description is not descriptive and helpful. If anyone can provide me some ideas or sample code to read this file would be greatful.
Hope someone will give reply to this :-)
Thanks & regards,
Swetha
The import directive is a Microsoft compiler's propietary prepocessor directive. What this directive does is reading any COM related import library and generate a C++ header file (at pre-compilation time).
Note: Import libraries may live inside DLL or OCX files.
Inside this header file generated at precomiplation time, live the interface definitions of the COM objects included in the import library. Once having these interface definitions, you can get access to the interfaces implementd by the COM objects, without interface defitions you can not access the COM objects; unless said COM objects implement the IDispatch interface.
So, if you are not using the Microsoft compiler, the import directive wont work.
What I did a couple of years ago to overcome this was creating a separate program that would read Import Libraries, and it would spit a C++ header file that would include the definitions of the COM object's interfaces defined inside said Import Libraries. You could do that if you are not using a MIcrosoft compiler.
Now if you are using the Microsoft compiler, you are ready to use the interfaces using some nifty templates like com_ptr<> if I remember correctly.
i.e,
#import "foo.ocx"
using fooclass;
...
com_ptr<IFoo> ifoo;
...
Now bringing an OCX control to life inside a Window without using MFC nor ATL is the closest thing to a punishment from hell you can ever come across in your lifetime; and by bringing it to life I mean displaying it as a control inside a Window, why? because you need to code a control container in your C++ aplication if you want to, that means implementing lots of interfaces.
I wont go any further to avoid confusing you with other details.
Good luck.