| | |
How to read .ocx file in C++ (Not MFC)
![]() |
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
a #import directive like
#import "<name of the ocx file or typelibrary>" no_namespace, raw_interfaces_only \
named_guids raw_native_types <any other #import attributes>
will generate a header file with the name <base name of tlb/ocx>.tlh. and this header is impliciltly #included.
the #import attributes specify options for generating the header file. this header contains C++ definitions of COM interfaces, types etc and can be directly used in your code.
instantiate the object using a CoCreateInstance. COM methods are seen by C++ as virtual functions. open the .tlh file to see the declarations and use the methods like normal virtual functions. once you are done, call Release instead of using delete.
#import "<name of the ocx file or typelibrary>" no_namespace, raw_interfaces_only \
named_guids raw_native_types <any other #import attributes>
will generate a header file with the name <base name of tlb/ocx>.tlh. and this header is impliciltly #included.
the #import attributes specify options for generating the header file. this header contains C++ definitions of COM interfaces, types etc and can be directly used in your code.
instantiate the object using a CoCreateInstance. COM methods are seen by C++ as virtual functions. open the .tlh file to see the declarations and use the methods like normal virtual functions. once you are done, call Release instead of using delete.
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
Hi,
Thanku very much for giving quick reply.
Actually I am very new to c++.So now I am having .ocx file.
Using #import "filename" ?I am trying to read that file.If I use #import directive it created *.tlh and .tli files.But it is giving some errors while using CoCreateInstandce function.
If you dont mind can any one send some simple sample code related to this?
Or where to call this CoCreateInstance function and which parameters need to give?
I hope will give reply as early as possible.
Thanks And Regards,
swetha.
Thanku very much for giving quick reply.
Actually I am very new to c++.So now I am having .ocx file.
Using #import "filename" ?I am trying to read that file.If I use #import directive it created *.tlh and .tli files.But it is giving some errors while using CoCreateInstandce function.
If you dont mind can any one send some simple sample code related to this?
Or where to call this CoCreateInstance function and which parameters need to give?
I hope will give reply as early as possible.
Thanks And Regards,
swetha.
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> ...some simple sample code related to this
c++ Syntax (Toggle Plain Text)
#include <iostream> #include <windows.h> #include <cassert> // disable a whole bunch of unnecessary (for me) stuff by no_* #import "C:\\Program Files\\iTunes\\ITDetector.ocx" \ no_namespace no_smart_pointers raw_interfaces_only \ raw_native_types no_implementation named_guids int main() { CoInitialize(0) ; { IiTunesDetector* pitd = 0 ; // CLSID_iTunesDetector, IID_IiTunesDetector are // picked up from itdetector.tlh (named_guids) HRESULT hr = CoCreateInstance( CLSID_iTunesDetector, 0, CLSCTX_ALL, IID_IiTunesDetector, // interface uuid reinterpret_cast<void**>(&pitd) ) ; assert( SUCCEEDED(hr) ) ; // iTunesVersion is a property (raw_interfaces_only) long version = 0 ; hr = pitd->get_iTunesVersion( &version ) ; assert( SUCCEEDED(hr) ) ; std::cout << "iTunes version is " << std::hex << std::showbase << version << '\n' ; pitd->Release() ; } CoUninitialize() ; }
Last edited by vijayan121; Nov 27th, 2007 at 10:13 am.
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
Hi vijayan,
How did you define "IID_IiTunesDetector" variable in your header file? I tried defining this variable from all possible ways .However, while compiling I am getting error as unexpected identifier for this variable.
Following is my code.
//////////////////////////////////////////////////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
I think u got my doubt.Can you clarify and send the sollution?Hope u will send the reply.
Thanks in Advance,
swetha.
How did you define "IID_IiTunesDetector" variable in your header file? I tried defining this variable from all possible ways .However, while compiling I am getting error as unexpected identifier for this variable.
Following is my code.
//////////////////////////////////////////////////
C++ Syntax (Toggle Plain Text)
#import "c:\WINNT\system32\mmap.ocx" int main() { CoInitialize(NULL); _DMMap* pMP = 0; HRESULT hr = CoCreateInstane(CLSID_DMMap,0,CLSCTX_ALL,IID_DMMap,reinterpret_cast <void**>(&pMP)); ......... ......... CoUninitialize(); }
I think u got my doubt.Can you clarify and send the sollution?Hope u will send the reply.
Thanks in Advance,
swetha.
Last edited by Ancient Dragon; Nov 28th, 2007 at 1:44 pm. Reason: add code tags
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> How did you define "IID_IiTunesDetector" variable in your header file?
it was defined for me in the generated .tlh header due to the presence
of the named_guids attribute in the #import directive
this is (an extract from) the .tlh header generated:
so i could use the named constants as in
alternatively i could have written
this would not require generation of named guid constants.
if you want to generate named guid constants, use named_guids attribute in the #import directive
without the no_namespace attribute for the #import,
all names imported would be inside a namespace (with the base name of the typelib).
or else use the __uuidof operator
in your case the uuid for the interface would be given by __uuidof( _DMMap )
in all cases, look in the generated .tlh file to get the correct identifiers.
eg. if you see struct /* coclass */ <name of class> ; in the header,
for the CLSID you should use __uuidof( <name of class> )
you don't know anything about using COM in C++, do you?
even if you get to somehow do this part now, you are going to face more problems
somewhere else sooner rather than later. perhaps you should take some time to
first read http://www.amazon.com/Inside-Microso.../dp/1572313498
and then http://www.amazon.com/Essential-COM-.../dp/0201634465
it was defined for me in the generated .tlh header due to the presence
of the named_guids attribute in the #import directive
this is (an extract from) the .tlh header generated:
C++ Syntax (Toggle Plain Text)
// ... // Forward references and typedefs struct __declspec(uuid("d6995525-b33a-4980-a106-9df58570cc66")) /* LIBID */ __ITDETECTORLib; struct /* coclass */ iTunesDetector; struct __declspec(uuid("45d2c838-0137-4e6a-aa3b-d39b4a1a1a28")) /* dual interface */ IiTunesDetector; // Type library items struct __declspec(uuid("d719897a-b07a-4c0c-aea9-9b663a28dfcb")) iTunesDetector; // [ default ] interface IiTunesDetector struct __declspec(uuid("45d2c838-0137-4e6a-aa3b-d39b4a1a1a28")) IiTunesDetector : IDispatch { // Raw methods provided by interface // ... virtual HRESULT __stdcall get_iTunesVersion ( /*[out,retval]*/ long * pVal ) = 0; // ... }; // Named GUID constants initializations extern "C" const GUID __declspec(selectany) LIBID_ITDETECTORLib = {0xd6995525,0xb33a,0x4980,{0xa1,0x06,0x9d,0xf5,0x85,0x70,0xcc,0x66}}; extern "C" const GUID __declspec(selectany) CLSID_iTunesDetector = {0xd719897a,0xb07a,0x4c0c,{0xae,0xa9,0x9b,0x66,0x3a,0x28,0xdf,0xcb}}; extern "C" const GUID __declspec(selectany) IID_IiTunesDetector = {0x45d2c838,0x0137,0x4e6a,{0xaa,0x3b,0xd3,0x9b,0x4a,0x1a,0x1a,0x28}}; // ...
so i could use the named constants as in
C++ Syntax (Toggle Plain Text)
CoCreateInstance( CLSID_iTunesDetector, 0, CLSCTX_ALL, IID_IiTunesDetector, reinterpret_cast<void**>(&pitd) ) ;
alternatively i could have written
C++ Syntax (Toggle Plain Text)
CoCreateInstance( __uuidof(iTunesDetector), 0, CLSCTX_ALL, __uuidof(IiTunesDetector), reinterpret_cast<void**>(&pitd) ) ;
if you want to generate named guid constants, use named_guids attribute in the #import directive
C++ Syntax (Toggle Plain Text)
#import "c:\WINNT\system32\mmap.ocx" named_guids no_namespace
all names imported would be inside a namespace (with the base name of the typelib).
or else use the __uuidof operator
in your case the uuid for the interface would be given by __uuidof( _DMMap )
in all cases, look in the generated .tlh file to get the correct identifiers.
eg. if you see struct /* coclass */ <name of class> ; in the header,
for the CLSID you should use __uuidof( <name of class> )
you don't know anything about using COM in C++, do you?
even if you get to somehow do this part now, you are going to face more problems
somewhere else sooner rather than later. perhaps you should take some time to
first read http://www.amazon.com/Inside-Microso.../dp/1572313498
and then http://www.amazon.com/Essential-COM-.../dp/0201634465
Last edited by vijayan121; Nov 28th, 2007 at 11:51 pm.
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
Hi vijayan,
this is (an extract from) my "MMap.tlh" header generated:
so now I am using the named constants as
But while compiling error is getting errors like
'MMap' :undeclared identifier
_DMMap' : no GUID has been associated with this object
Actually I am not having idea about COM in C++. Surely I will see those links and I will try to learn about this.
Please tell me what I did wrong?Or you tell me how u r generating named guid constants using # import directive?
Thankyou very much for ur prompt reply.
Thanks in advance,
swetha.
this is (an extract from) my "MMap.tlh" header generated:
C++ Syntax (Toggle Plain Text)
/////////........................................./////////// struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a")) /* dispinterface */ _DMMap; struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a")) /* dispinterface */ _DMMapEvents; struct /* coclass */ MMap; // // Smart pointer typedef declarations // _COM_SMARTPTR_TYPEDEF(_DMMap, __uuidof(IDispatch)); _COM_SMARTPTR_TYPEDEF(_DMMapEvents, __uuidof(IDispatch)); // struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a")) _DMMap : IDispatch { // // Property data // __declspec(property(get=GetMapNorth,put=PutMapNorth)) double MapNorth; __declspec(property(get=GetMapSouth,put=PutMapSouth)) double MapSouth; __declspec(property(get=GetMapEast,put=PutMapEast)) double MapEast; ...... ...... ...... }; struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a")) _DMMapEvents : IDispatch { // // Wrapper methods for error-handling // // Methods: HRESULT MovePosition ( double X, double Y ); HRESULT Click ( ); ..... ...... ..... }; struct __declspec(uuid("d5f63c24-b3d3-11d0-b8f0-0020af344e0a")) MMap; // [ default ] dispinterface _DMMap // [ default, source ] dispinterface _DMMapEvents // // Named GUID constants initializations // extern "C" const GUID __declspec(selectany) LIBID_MMAPLib = {0xd5f63c21,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) DIID__DMMap = {0xd5f63c22,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) DIID__DMMapEvents = {0xd5f63c23,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) CLSID_MMap = {0xd5f63c24,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
so now I am using the named constants as
C++ Syntax (Toggle Plain Text)
///mmap.cpp #import "c:\WINNT\system32\MMap.ocx" void main() { CoInitialize( NULL); _DMMap* pMP = 0; HRESULT hr = CoCreateInstance( __uuidof(MMap), NULL, CLSCTX_ALL, IID_DMMap, reinterpret_cast <void**>(&pMP)); assert(SUCCEEDED(hr)); hr = pMP->GetMapID(); assert(SUCCEEDED(hr)); pMP ->Release(); CoUninitialize(); }
'MMap' :undeclared identifier
_DMMap' : no GUID has been associated with this object
Actually I am not having idea about COM in C++. Surely I will see those links and I will try to learn about this.
Please tell me what I did wrong?Or you tell me how u r generating named guid constants using # import directive?
Thankyou very much for ur prompt reply.
Thanks in advance,
swetha.
Last edited by cscgal; Dec 3rd, 2007 at 10:13 pm. Reason: Added code tags
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> But while compiling error is getting errors like 'MMap' :undeclared identifier
looks like you have not used the no_namespace attribute; so the identifiers are in a namespace in the .tlh
also looks like you have not read my previous post or if you have read it, you haven't understood it.
in any case, to avoid getting into what in programming would be called an infinite loop, post the entire contents of the generated .tlh file. also the actual #import statement that you used.
on second thoughts, don't post it; just attach it to your post as a plain text file. that way, we would not have to contend with the intricacies of using code tags and the perversities indulged in by aniweb's code formatter and the preview facility provided.
looks like you have not used the no_namespace attribute; so the identifiers are in a namespace in the .tlh
also looks like you have not read my previous post or if you have read it, you haven't understood it.
in any case, to avoid getting into what in programming would be called an infinite loop, post the entire contents of the generated .tlh file. also the actual #import statement that you used.
on second thoughts, don't post it; just attach it to your post as a plain text file. that way, we would not have to contend with the intricacies of using code tags and the perversities indulged in by aniweb's code formatter and the preview facility provided.
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
/*************************************************/
This is mmap.tlh header file
/***********************************************************/
/////////////////////////////////////////////////////////////////
These three are files which i am using now.
Thanks in Advance,
swetha.
This is mmap.tlh header file
/***********************************************************/
C++ Syntax (Toggle Plain Text)
#pragma once #pragma pack(push, 8) #include <comdef.h> namespace MMAPLib { // // Forward references and typedefs // struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a")) /* dispinterface */ _DMMap; struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a")) /* dispinterface */ _DMMapEvents; struct /* coclass */ MMap; // // Smart pointer typedef declarations // _COM_SMARTPTR_TYPEDEF(_DMMap, __uuidof(IDispatch)); _COM_SMARTPTR_TYPEDEF(_DMMapEvents, __uuidof(IDispatch)); // // Type library items // enum enumMoveMapMode { Stationary = 0, Floating = 1 }; enum enumBevelStyle { BevelNone = 0, BevelRaised = 1, BevelLowered = 2 }; enum enumObjectSymbol { SymbolWaypoint = 0, SymbolNavAid = 1, SymbolAirport = 2, SymbolAirplane = 3, SymbolPicture = 4, SymbolUserDefined = 5 }; enum enumObjectStyle { Transparent = 0, Opaque = 1 }; enum enumLineStyle { Solid = 0, Dash = 1, Dot = 2, DashDot = 3, DashDotDot = 4 }; enum enumWaypointLineStyle { WaypointLineNone = 0, WaypointLineSolid = 1, WaypointLineDash = 2, WaypointLineDot = 3, WaypointLineDashDot = 4, WaypointLineDashDotDot = 5 }; enum enumObjectFOVStyle { NoFOV = 0, BoundedFOV = 1, ShadedFOV = 2 }; enum enumGridStyle { NoGrid = 0, HorizontalGrid = 1, VerticalGrid = 2, BothGrid = 3 }; enum enumCaptionOrientation { HorizontalCaption = 0, VerticalLeftCaption = 1, VerticalRightCaption = 2 }; struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a")) _DMMap : IDispatch { // // Property data // __declspec(property(get=GetMapNorth,put=PutMapNorth)) double MapNorth; __declspec(property(get=GetMapSouth,put=PutMapSouth)) double MapSouth; __declspec(property(get=GetMapEast,put=PutMapEast)) double MapEast; __declspec(property(get=GetMapWest,put=PutMapWest)) double MapWest; __declspec(property(get=GetMappingMode,put=PutMappingMode)) enum enumMoveMapMode MappingMode; __declspec(property(get=GetMaps,put=PutMaps)) short Maps; __declspec(property(get=GetMapID,put=PutMapID)) short MapID; __declspec(property(get=GetCaption,put=PutCaption)) _bstr_t Caption; __declspec(property(get=GetCaptionColor,put=PutCaptionColor)) OLE_COLOR CaptionColor; __declspec(property(get=GetCaptionID,put=PutCaptionID)) short CaptionID; __declspec(property(get=GetCaptionFontID,put=PutCaptionFontID)) short CaptionFontID; __declspec(property(get=GetCaptions,put=PutCaptions)) short Captions; __declspec(property(get=GetCaptionX,put=PutCaptionX)) double CaptionX; __declspec(property(get=GetCaptionY,put=PutCaptionY)) double CaptionY; __declspec(property(get=GetBackPicture,put=PutBackPicture)) PicturePtr BackPicture; __declspec(property(get=GetBevelInner,put=PutBevelInner)) enum enumBevelStyle BevelInner; __declspec(property(get=GetBevelOuter,put=PutBevelOuter)) enum enumBevelStyle BevelOuter; __declspec(property(get=GetBevelWidth,put=PutBevelWidth)) short BevelWidth; __declspec(property(get=GetBorderWidth,put=PutBorderWidth)) short BorderWidth; __declspec(property(get=GetFontName,put=PutFontName)) _bstr_t FontName; __declspec(property(get=GetFontSize,put=PutFontSize)) float FontSize; __declspec(property(get=GetFontID,put=PutFontID)) short FontID; __declspec(property(get=GetFont,put=PutFont)) FontPtr Font; __declspec(property(get=GetFonts,put=PutFonts)) short Fonts; __declspec(property(get=GetFontBold,put=PutFontBold)) VARIANT_BOOL FontBold; __declspec(property(get=GetFontItalic,put=PutFontItalic)) VARIANT_BOOL FontItalic; __declspec(property(get=GetFontStrikethru,put=PutFontStrikethru)) VARIANT_BOOL FontStrikethru; __declspec(property(get=GetFontUnderline,put=PutFontUnderline)) VARIANT_BOOL FontUnderline; __declspec(property(get=GetAutoRedraw,put=PutAutoRedraw)) VARIANT_BOOL AutoRedraw; __declspec(property(get=GetMapPicture,put=PutMapPicture)) PicturePtr MapPicture; __declspec(property(get=GetBackColor,put=PutBackColor)) OLE_COLOR BackColor; __declspec(property(get=GetViewCenterX,put=PutViewCenterX)) double ViewCenterX; __declspec(property(get=GetViewCenterY,put=PutViewCenterY)) double ViewCenterY; __declspec(property(get=GetViewRadius,put=PutViewRadius)) double ViewRadius; __declspec(property(get=GetViews,put=PutViews)) short Views; __declspec(property(get=GetViewID,put=PutViewID)) short ViewID; __declspec(property(get=GetObjects,put=PutObjects)) short Objects; __declspec(property(get=GetObjectID,put=PutObjectID)) short ObjectID; __declspec(property(get=GetObjectSymbol,put=PutObjectSymbol)) enum enumObjectSymbol ObjectSymbol; __declspec(property(get=GetObjectColor,put=PutObjectColor)) OLE_COLOR ObjectColor; __declspec(property(get=GetObjectOrientation,put=PutObjectOrientation)) double ObjectOrientation; __declspec(property(get=GetObjectShape,put=PutObjectShape)) _bstr_t ObjectShape; __declspec(property(get=GetObjectCaption,put=PutObjectCaption)) _bstr_t ObjectCaption; __declspec(property(get=GetObjectScale,put=PutObjectScale)) double ObjectScale; __declspec(property(get=GetWaypoints,put=PutWaypoints)) short Waypoints; __declspec(property(get=GetWaypointStyle,put=PutWaypointStyle)) enum enumObjectStyle WaypointStyle; __declspec(property(get=GetWaypointID,put=PutWaypointID)) short WaypointID; __declspec(property(get=GetWaypointCaption,put=PutWaypointCaption)) _bstr_t WaypointCaption; __declspec(property(get=GetWaypointOrientation,put=PutWaypointOrientation)) double WaypointOrientation; __declspec(property(get=GetWaypointScale,put=PutWaypointScale)) double WaypointScale; __declspec(property(get=GetWaypointSymbol,put=PutWaypointSymbol)) enum enumObjectSymbol WaypointSymbol; __declspec(property(get=GetWaypointX,put=PutWaypointX)) double WaypointX; __declspec(property(get=GetWaypointY,put=PutWaypointY)) double WaypointY; __declspec(property(get=GetWaypointColor,put=PutWaypointColor)) OLE_COLOR WaypointColor; __declspec(property(get=GetObjectStyle,put=PutObjectStyle)) enum enumObjectStyle ObjectStyle; __declspec(property(get=GetObjectX,put=PutObjectX)) double ObjectX; __declspec(property(get=GetObjectY,put=PutObjectY)) double ObjectY; __declspec(property(get=GetWaypointLineColor,put=PutWaypointLineColor)) OLE_COLOR WaypointLineColor; __declspec(property(get=GetWaypointLineStyle,put=PutWaypointLineStyle)) enum enumWaypointLineStyle WaypointLineStyle; __declspec(property(get=GetObjectBreadTrail,put=PutObjectBreadTrail)) VARIANT_BOOL ObjectBreadTrail; __declspec(property(get=GetObjectHeading,put=PutObjectHeading)) double ObjectHeading; __declspec(property(get=GetObjectHeadingLineColor,put=PutObjectHeadingLineColor)) OLE_COLOR ObjectHeadingLineColor; __declspec(property(get=GetObjectHeadingLineRange,put=PutObjectHeadingLineRange)) double ObjectHeadingLineRange; __declspec(property(get=GetObjectHeadingLineWidth,put=PutObjectHeadingLineWidth)) short ObjectHeadingLineWidth; __declspec(property(get=GetObjectHeadingShow,put=PutObjectHeadingShow)) VARIANT_BOOL ObjectHeadingShow; __declspec(property(get=GetObjectFOVStyle,put=PutObjectFOVStyle)) enum enumObjectFOVStyle ObjectFOVStyle; __declspec(property(get=GetObjectFOV,put=PutObjectFOV)) double ObjectFOV; __declspec(property(get=GetObjectFOVLineColor,put=PutObjectFOVLineColor)) OLE_COLOR ObjectFOVLineColor; __declspec(property(get=GetObjectFOVLineRange,put=PutObjectFOVLineRange)) double ObjectFOVLineRange; __declspec(property(get=GetObjectFOVLineWidth,put=PutObjectFOVLineWidth)) short ObjectFOVLineWidth; __declspec(property(get=GetObjectPicture,put=PutObjectPicture)) PicturePtr ObjectPicture; __declspec(property(get=GetGridStyle,put=PutGridStyle)) enum enumGridStyle GridStyle; __declspec(property(get=GetGridXDelta,put=PutGridXDelta)) double GridXDelta; __declspec(property(get=GetGridYDelta,put=PutGridYDelta)) double GridYDelta; __declspec(property(get=GetGridColor,put=PutGridColor)) OLE_COLOR GridColor; __declspec(property(get=GetViewObjectID,put=PutViewObjectID)) short ViewObjectID; __declspec(property(get=GetWaypointLineWidth,put=PutWaypointLineWidth)) short WaypointLineWidth; __declspec(property(get=GetGridLineWidth,put=PutGridLineWidth)) short GridLineWidth; __declspec(property(get=GetGridLineStyle,put=PutGridLineStyle)) enum enumLineStyle GridLineStyle; __declspec(property(get=GetGridRefY,put=PutGridRefY)) double GridRefY; __declspec(property(get=GetGridRefX,put=PutGridRefX)) double GridRefX; __declspec(property(get=GetObjectZ,put=PutObjectZ)) double ObjectZ; __declspec(property(get=GetWaypointZ,put=PutWaypointZ)) double WaypointZ; __declspec(property(get=GetWaypointShape,put=PutWaypointShape)) _bstr_t WaypointShape; __declspec(property(get=GetWaypointPicture,put=PutWaypointPicture)) PicturePtr WaypointPicture; __declspec(property(get=GetZoomEnabled,put=PutZoomEnabled)) VARIANT_BOOL ZoomEnabled; __declspec(property(get=GetPanEnabled,put=PutPanEnabled)) VARIANT_BOOL PanEnabled; __declspec(property(get=GetCaptionOrientation,put=PutCaptionOrientation)) enum enumCaptionOrientation CaptionOrientation; __declspec(property(get=GetOutline,put=PutOutline)) VARIANT_BOOL Outline; __declspec(property(get=GetOutlineTitle,put=PutOutlineTitle)) _bstr_t OutlineTitle; __declspec(property(get=GetOutlineColor,put=PutOutlineColor)) OLE_COLOR OutlineColor; __declspec(property(get=GetOutlineWidth,put=PutOutlineWidth)) short OutlineWidth; __declspec(property(get=GetOutlineAlign,put=PutOutlineAlign)) short OutlineAlign; __declspec(property(get=GetEnabled,put=PutEnabled)) VARIANT_BOOL Enabled; __declspec(property(get=GetSingleBuffer,put=PutSingleBuffer)) VARIANT_BOOL SingleBuffer; __declspec(property(get=GetFocusOutline,put=PutFocusOutline)) VARIANT_BOOL FocusOutline; __declspec(property(get=GetConfiguration,put=PutConfiguration)) _bstr_t Configuration; // // Wrapper methods for error-handling // // Methods: HRESULT Redraw ( ); HRESULT RedrawStatic ( ); HRESULT ShowPropertyPage ( ); HRESULT SetWaypointData ( const _variant_t & array ); HRESULT SetPositionData ( short ObjectID, double X, double Y, double Z ); HRESULT AboutBox ( ); // Properties: double GetMapNorth ( ); void PutMapNorth ( double _val ); double GetMapSouth ( ); void PutMapSouth ( double _val ); double GetMapEast ( ); void PutMapEast ( double _val ); double GetMapWest ( ); void PutMapWest ( double _val ); enum enumMoveMapMode GetMappingMode ( ); void PutMappingMode ( enum enumMoveMapMode _val ); short GetMaps ( ); void PutMaps ( short _val ); short GetMapID ( ); void PutMapID ( short _val ); _bstr_t GetCaption ( ); void PutCaption ( _bstr_t _val ); OLE_COLOR GetCaptionColor ( ); void PutCaptionColor ( OLE_COLOR _val ); short GetCaptionID ( ); void PutCaptionID ( short _val ); short GetCaptionFontID ( ); void PutCaptionFontID ( short _val ); short GetCaptions ( ); void PutCaptions ( short _val ); double GetCaptionX ( ); void PutCaptionX ( double _val ); double GetCaptionY ( ); void PutCaptionY ( double _val ); PicturePtr GetBackPicture ( ); void PutBackPicture ( struct Picture * _val ); enum enumBevelStyle GetBevelInner ( ); void PutBevelInner ( enum enumBevelStyle _val ); enum enumBevelStyle GetBevelOuter ( ); void PutBevelOuter ( enum enumBevelStyle _val ); short GetBevelWidth ( ); void PutBevelWidth ( short _val ); short GetBorderWidth ( ); void PutBorderWidth ( short _val ); _bstr_t GetFontName ( ); void PutFontName ( _bstr_t _val ); float GetFontSize ( ); void PutFontSize ( float _val ); short GetFontID ( ); void PutFontID ( short _val ); FontPtr GetFont ( ); void PutFont ( struct Font * _val ); short GetFonts ( ); void PutFonts ( short _val ); VARIANT_BOOL GetFontBold ( ); void PutFontBold ( VARIANT_BOOL _val ); VARIANT_BOOL GetFontItalic ( ); void PutFontItalic ( VARIANT_BOOL _val ); VARIANT_BOOL GetFontStrikethru ( ); void PutFontStrikethru ( VARIANT_BOOL _val ); VARIANT_BOOL GetFontUnderline ( ); void PutFontUnderline ( VARIANT_BOOL _val ); VARIANT_BOOL GetAutoRedraw ( ); void PutAutoRedraw ( VARIANT_BOOL _val ); PicturePtr GetMapPicture ( ); void PutMapPicture ( struct Picture * _val ); OLE_COLOR GetBackColor ( ); void PutBackColor ( OLE_COLOR _val ); double GetViewCenterX ( ); void PutViewCenterX ( double _val ); double GetViewCenterY ( ); void PutViewCenterY ( double _val ); double GetViewRadius ( ); void PutViewRadius ( double _val ); short GetViews ( ); void PutViews ( short _val ); short GetViewID ( ); void PutViewID ( short _val ); short GetObjects ( ); void PutObjects ( short _val ); short GetObjectID ( ); void PutObjectID ( short _val ); enum enumObjectSymbol GetObjectSymbol ( ); void PutObjectSymbol ( enum enumObjectSymbol _val ); OLE_COLOR GetObjectColor ( ); void PutObjectColor ( OLE_COLOR _val ); double GetObjectOrientation ( ); void PutObjectOrientation ( double _val ); _bstr_t GetObjectShape ( ); void PutObjectShape ( _bstr_t _val ); _bstr_t GetObjectCaption ( ); void PutObjectCaption ( _bstr_t _val ); double GetObjectScale ( ); void PutObjectScale ( double _val ); short GetWaypoints ( ); void PutWaypoints ( short _val ); enum enumObjectStyle GetWaypointStyle ( ); void PutWaypointStyle ( enum enumObjectStyle _val ); short GetWaypointID ( ); void PutWaypointID ( short _val ); _bstr_t GetWaypointCaption ( ); void PutWaypointCaption ( _bstr_t _val ); double GetWaypointOrientation ( ); void PutWaypointOrientation ( double _val ); double GetWaypointScale ( ); void PutWaypointScale ( double _val ); enum enumObjectSymbol GetWaypointSymbol ( ); void PutWaypointSymbol ( enum enumObjectSymbol _val ); double GetWaypointX ( ); void PutWaypointX ( double _val ); double GetWaypointY ( ); void PutWaypointY ( double _val ); OLE_COLOR GetWaypointColor ( ); void PutWaypointColor ( OLE_COLOR _val ); enum enumObjectStyle GetObjectStyle ( ); void PutObjectStyle ( enum enumObjectStyle _val ); double GetObjectX ( ); void PutObjectX ( double _val ); double GetObjectY ( ); void PutObjectY ( double _val ); OLE_COLOR GetWaypointLineColor ( ); void PutWaypointLineColor ( OLE_COLOR _val ); enum enumWaypointLineStyle GetWaypointLineStyle ( ); void PutWaypointLineStyle ( enum enumWaypointLineStyle _val ); VARIANT_BOOL GetObjectBreadTrail ( ); void PutObjectBreadTrail ( VARIANT_BOOL _val ); double GetObjectHeading ( ); void PutObjectHeading ( double _val ); OLE_COLOR GetObjectHeadingLineColor ( ); void PutObjectHeadingLineColor ( OLE_COLOR _val ); double GetObjectHeadingLineRange ( ); void PutObjectHeadingLineRange ( double _val ); short GetObjectHeadingLineWidth ( ); void PutObjectHeadingLineWidth ( short _val ); VARIANT_BOOL GetObjectHeadingShow ( ); void PutObjectHeadingShow ( VARIANT_BOOL _val ); enum enumObjectFOVStyle GetObjectFOVStyle ( ); void PutObjectFOVStyle ( enum enumObjectFOVStyle _val ); double GetObjectFOV ( ); void PutObjectFOV ( double _val ); OLE_COLOR GetObjectFOVLineColor ( ); void PutObjectFOVLineColor ( OLE_COLOR _val ); double GetObjectFOVLineRange ( ); void PutObjectFOVLineRange ( double _val ); short GetObjectFOVLineWidth ( ); void PutObjectFOVLineWidth ( short _val ); PicturePtr GetObjectPicture ( ); void PutObjectPicture ( struct Picture * _val ); enum enumGridStyle GetGridStyle ( ); void PutGridStyle ( enum enumGridStyle _val ); double GetGridXDelta ( ); void PutGridXDelta ( double _val ); double GetGridYDelta ( ); void PutGridYDelta ( double _val ); OLE_COLOR GetGridColor ( ); void PutGridColor ( OLE_COLOR _val ); short GetViewObjectID ( ); void PutViewObjectID ( short _val ); short GetWaypointLineWidth ( ); void PutWaypointLineWidth ( short _val ); short GetGridLineWidth ( ); void PutGridLineWidth ( short _val ); enum enumLineStyle GetGridLineStyle ( ); void PutGridLineStyle ( enum enumLineStyle _val ); double GetGridRefY ( ); void PutGridRefY ( double _val ); double GetGridRefX ( ); void PutGridRefX ( double _val ); double GetObjectZ ( ); void PutObjectZ ( double _val ); double GetWaypointZ ( ); void PutWaypointZ ( double _val ); _bstr_t GetWaypointShape ( ); void PutWaypointShape ( _bstr_t _val ); PicturePtr GetWaypointPicture ( ); void PutWaypointPicture ( struct Picture * _val ); VARIANT_BOOL GetZoomEnabled ( ); void PutZoomEnabled ( VARIANT_BOOL _val ); VARIANT_BOOL GetPanEnabled ( ); void PutPanEnabled ( VARIANT_BOOL _val ); enum enumCaptionOrientation GetCaptionOrientation ( ); void PutCaptionOrientation ( enum enumCaptionOrientation _val ); VARIANT_BOOL GetOutline ( ); void PutOutline ( VARIANT_BOOL _val ); _bstr_t GetOutlineTitle ( ); void PutOutlineTitle ( _bstr_t _val ); OLE_COLOR GetOutlineColor ( ); void PutOutlineColor ( OLE_COLOR _val ); short GetOutlineWidth ( ); void PutOutlineWidth ( short _val ); short GetOutlineAlign ( ); void PutOutlineAlign ( short _val ); VARIANT_BOOL GetEnabled ( ); void PutEnabled ( VARIANT_BOOL _val ); VARIANT_BOOL GetSingleBuffer ( ); void PutSingleBuffer ( VARIANT_BOOL _val ); VARIANT_BOOL GetFocusOutline ( ); void PutFocusOutline ( VARIANT_BOOL _val ); _bstr_t GetConfiguration ( ); void PutConfiguration ( _bstr_t _val ); }; struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a")) _DMMapEvents : IDispatch { // // Wrapper methods for error-handling // // Methods: HRESULT MovePosition ( double X, double Y ); HRESULT Click ( ); HRESULT DblClick ( ); HRESULT KeyDown ( short * KeyCode, short Shift ); HRESULT KeyPress ( short * KeyAscii ); HRESULT KeyUp ( short * KeyCode, short Shift ); HRESULT MouseDown ( short Button, short Shift, OLE_XPOS_PIXELS X, OLE_YPOS_PIXELS Y ); HRESULT MouseMove ( short Button, short Shift, OLE_XPOS_PIXELS X, OLE_YPOS_PIXELS Y ); HRESULT MouseUp ( short Button, short Shift, OLE_XPOS_PIXELS X, OLE_YPOS_PIXELS Y ); HRESULT ClickPosition ( short ObjectID, double X, double Y ); }; struct __declspec(uuid("d5f63c24-b3d3-11d0-b8f0-0020af344e0a")) MMap; // [ default ] dispinterface _DMMap // [ default, source ] dispinterface _DMMapEvents // // Named GUID constants initializations // extern "C" const GUID __declspec(selectany) LIBID_MMAPLib = {0xd5f63c21,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) DIID__DMMap = {0xd5f63c22,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) DIID__DMMapEvents = {0xd5f63c23,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; extern "C" const GUID __declspec(selectany) CLSID_MMap = {0xd5f63c24,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}}; // // Wrapper method implementations // #include "MMap.tli" } // namespace MMAPLib #pragma pack(pop) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /************************************************/ This is my image.cpp file /************************************************/ // #import "c:\WINNT\system32\MMap.ocx" \ named_guids LIBID_MMAPLib,DIID_DMMap,DIID_DMMapEvents,CLSID_MMap \ no_namespace MMAPLib #include "stdafx.h" #include "image.h" #include <windows.h> #include <winerror.h> #include <stdio.h> #include <iostream> #include <assert.h> #include <cassert> void main() { CoInitialize( NULL); _DMMap* pMP = 0; HRESULT hr = CoCreateInstance( __uuidof(MMap),//class identifier of the object NULL, CLSCTX_ALL,// context for running executable code DIID__DMMap,//reference to the identifier of the inerface reinterpret_cast <void**>(&pMP));//interface pointer requested in riid assert(SUCCEEDED(hr)); hr = pMP->GetMapID(); hr = pMP->GetMapNorth(); hr = pMP->GetMapEast(); hr = pMP->GetMapWest(); hr = pMP->GetMapSouth(); assert(SUCCEEDED(hr)); printf("reading the activeX control file "); pMP ->Release(); CoUninitialize(); } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /******************************************************/ This is my image.h file /*********************************************************/ #include <windows.h> #include <iostream.h> class _DMMap { public: _DMMap(); double GetMapID(); void PutMapID(double); double GetMapEast(); void PutMapEast(double); double GetMapWest(); void PutMapWest(double); double GetMapNorth(); void PutMapNorth(double); double GetMapSouth(); void PutMapSouth(double); double Release(); ~_DMMap(); }; _DMMap DIID__DMMap; class _DMMapEvents { public: HRESULT MovePosition ( double X,double Y ); HRESULT Click ( ); HRESULT DblClick ( ); }; _DMMapEvents DIID__DMMapEvents;
/////////////////////////////////////////////////////////////////
These three are files which i am using now.
Thanks in Advance,
swetha.
Last edited by cscgal; Dec 3rd, 2007 at 10:14 pm. Reason: Added code tags
![]() |
Similar Threads
- Read text file to a certain point (C#)
- Read XML File in C/C++ (C++)
- read text file (C#)
- using a "for" loop to read a text file (VB.NET)
- read data from file (C++)
- read a dat file through C (C)
Other Threads in the C++ Forum
- Previous Thread: infinite loop in recursion-no clue
- Next Thread: conflict graph
| Thread Tools | Search this Thread |
addition api array base based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email embed encryption error erroraftercompilation excel file forms fstream function functions game getline givemetehcodez gmail graph gui homework homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix matrix3d memory multiple news node output parameter pointer problem program programming project python random read recursion reference rpg std::coutwstring string strings temperature template test text text-file tree url variable vector video visualization win32 windows winsock word wordfrequency wxwidgets






