How to read .ocx file in C++ (Not MFC)

Reply

Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

How to read .ocx file in C++ (Not MFC)

 
0
  #1
Nov 23rd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #2
Nov 24th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #3
Nov 27th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #4
Nov 27th, 2007
> ...some simple sample code related to this
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <cassert>
  4.  
  5. // disable a whole bunch of unnecessary (for me) stuff by no_*
  6. #import "C:\\Program Files\\iTunes\\ITDetector.ocx" \
  7. no_namespace no_smart_pointers raw_interfaces_only \
  8. raw_native_types no_implementation named_guids
  9.  
  10. int main()
  11. {
  12. CoInitialize(0) ;
  13. {
  14. IiTunesDetector* pitd = 0 ;
  15. // CLSID_iTunesDetector, IID_IiTunesDetector are
  16. // picked up from itdetector.tlh (named_guids)
  17. HRESULT hr = CoCreateInstance( CLSID_iTunesDetector,
  18. 0,
  19. CLSCTX_ALL,
  20. IID_IiTunesDetector, // interface uuid
  21. reinterpret_cast<void**>(&pitd) ) ;
  22. assert( SUCCEEDED(hr) ) ;
  23.  
  24.  
  25. // iTunesVersion is a property (raw_interfaces_only)
  26. long version = 0 ;
  27. hr = pitd->get_iTunesVersion( &version ) ;
  28. assert( SUCCEEDED(hr) ) ;
  29. std::cout << "iTunes version is " << std::hex
  30. << std::showbase << version << '\n' ;
  31.  
  32. pitd->Release() ;
  33. }
  34. CoUninitialize() ;
  35. }
Last edited by vijayan121; Nov 27th, 2007 at 10:13 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #5
Nov 27th, 2007
Hi vijayan,
Thanks a lot for ur prompt response.I will try tomarrow.

The .ocx file contains the map.So I need to read that file and display that map.I think using ur code I can achieve this one.

Thanks And Regards,
swetha.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #6
Nov 28th, 2007
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.
//////////////////////////////////////////////////
  1. #import "c:\WINNT\system32\mmap.ocx"
  2. int main()
  3. {
  4. CoInitialize(NULL);
  5. _DMMap* pMP = 0;
  6. HRESULT hr = CoCreateInstane(CLSID_DMMap,0,CLSCTX_ALL,IID_DMMap,reinterpret_cast <void**>(&pMP));
  7. .........
  8. .........
  9. CoUninitialize();
  10. }
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #7
Nov 28th, 2007
> 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:
  1. // ...
  2. // Forward references and typedefs
  3. struct __declspec(uuid("d6995525-b33a-4980-a106-9df58570cc66"))
  4. /* LIBID */ __ITDETECTORLib;
  5. struct /* coclass */ iTunesDetector;
  6. struct __declspec(uuid("45d2c838-0137-4e6a-aa3b-d39b4a1a1a28"))
  7. /* dual interface */ IiTunesDetector;
  8.  
  9. // Type library items
  10. struct __declspec(uuid("d719897a-b07a-4c0c-aea9-9b663a28dfcb"))
  11. iTunesDetector;
  12. // [ default ] interface IiTunesDetector
  13.  
  14. struct __declspec(uuid("45d2c838-0137-4e6a-aa3b-d39b4a1a1a28"))
  15. IiTunesDetector : IDispatch
  16. {
  17. // Raw methods provided by interface
  18. // ...
  19. virtual HRESULT __stdcall get_iTunesVersion (
  20. /*[out,retval]*/ long * pVal ) = 0;
  21. // ...
  22. };
  23.  
  24. // Named GUID constants initializations
  25. extern "C" const GUID __declspec(selectany) LIBID_ITDETECTORLib =
  26. {0xd6995525,0xb33a,0x4980,{0xa1,0x06,0x9d,0xf5,0x85,0x70,0xcc,0x66}};
  27. extern "C" const GUID __declspec(selectany) CLSID_iTunesDetector =
  28. {0xd719897a,0xb07a,0x4c0c,{0xae,0xa9,0x9b,0x66,0x3a,0x28,0xdf,0xcb}};
  29. extern "C" const GUID __declspec(selectany) IID_IiTunesDetector =
  30. {0x45d2c838,0x0137,0x4e6a,{0xaa,0x3b,0xd3,0x9b,0x4a,0x1a,0x1a,0x28}};
  31. // ...

so i could use the named constants as in
  1. CoCreateInstance( CLSID_iTunesDetector, 0,
  2. CLSCTX_ALL,
  3. IID_IiTunesDetector,
  4. reinterpret_cast<void**>(&pitd) ) ;

alternatively i could have written
  1. CoCreateInstance( __uuidof(iTunesDetector), 0,
  2. CLSCTX_ALL,
  3. __uuidof(IiTunesDetector),
  4. reinterpret_cast<void**>(&pitd) ) ;
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
  1. #import "c:\WINNT\system32\mmap.ocx" named_guids no_namespace
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
Last edited by vijayan121; Nov 28th, 2007 at 11:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #8
Nov 29th, 2007
Hi vijayan,

this is (an extract from) my "MMap.tlh" header generated:
  1. /////////.........................................///////////
  2.  
  3. struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a"))
  4. /* dispinterface */ _DMMap;
  5.  
  6. struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a"))
  7. /* dispinterface */ _DMMapEvents;
  8. struct /* coclass */ MMap;
  9.  
  10. //
  11. // Smart pointer typedef declarations
  12. //
  13.  
  14. _COM_SMARTPTR_TYPEDEF(_DMMap, __uuidof(IDispatch));
  15. _COM_SMARTPTR_TYPEDEF(_DMMapEvents, __uuidof(IDispatch));
  16.  
  17. //
  18. struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a"))
  19. _DMMap : IDispatch
  20. {
  21. //
  22. // Property data
  23. //
  24.  
  25. __declspec(property(get=GetMapNorth,put=PutMapNorth))
  26. double MapNorth;
  27. __declspec(property(get=GetMapSouth,put=PutMapSouth))
  28. double MapSouth;
  29. __declspec(property(get=GetMapEast,put=PutMapEast))
  30. double MapEast;
  31. ......
  32. ......
  33. ......
  34. };
  35. struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a"))
  36. _DMMapEvents : IDispatch
  37. {
  38. //
  39. // Wrapper methods for error-handling
  40. //
  41.  
  42. // Methods:
  43. HRESULT MovePosition (
  44. double X,
  45. double Y );
  46. HRESULT Click ( );
  47. .....
  48. ......
  49. .....
  50. };
  51. struct __declspec(uuid("d5f63c24-b3d3-11d0-b8f0-0020af344e0a"))
  52. MMap;
  53. // [ default ] dispinterface _DMMap
  54. // [ default, source ] dispinterface _DMMapEvents
  55. //
  56. // Named GUID constants initializations
  57. //
  58.  
  59. extern "C" const GUID __declspec(selectany) LIBID_MMAPLib =
  60. {0xd5f63c21,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  61. extern "C" const GUID __declspec(selectany) DIID__DMMap =
  62. {0xd5f63c22,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  63. extern "C" const GUID __declspec(selectany) DIID__DMMapEvents =
  64. {0xd5f63c23,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  65. extern "C" const GUID __declspec(selectany) CLSID_MMap =
  66. {0xd5f63c24,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};

so now I am using the named constants as
  1. ///mmap.cpp
  2. #import "c:\WINNT\system32\MMap.ocx"
  3.  
  4. void main()
  5. {
  6. CoInitialize( NULL);
  7.  
  8. _DMMap* pMP = 0;
  9. HRESULT hr = CoCreateInstance( __uuidof(MMap),
  10. NULL,
  11. CLSCTX_ALL,
  12. IID_DMMap,
  13. reinterpret_cast <void**>(&pMP));
  14. assert(SUCCEEDED(hr));
  15. hr = pMP->GetMapID();
  16. assert(SUCCEEDED(hr));
  17. pMP ->Release();
  18. CoUninitialize();
  19. }
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.
Last edited by cscgal; Dec 3rd, 2007 at 10:13 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #9
Nov 29th, 2007
> 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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 22
Reputation: swethakiran is an unknown quantity at this point 
Solved Threads: 0
swethakiran swethakiran is offline Offline
Newbie Poster

Re: How to read .ocx file in C++ (Not MFC)

 
0
  #10
Nov 29th, 2007
/*************************************************/
This is mmap.tlh header file
/***********************************************************/
  1. #pragma once
  2. #pragma pack(push, 8)
  3.  
  4. #include <comdef.h>
  5.  
  6. namespace MMAPLib {
  7.  
  8. //
  9. // Forward references and typedefs
  10. //
  11.  
  12. struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a"))
  13. /* dispinterface */ _DMMap;
  14. struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a"))
  15. /* dispinterface */ _DMMapEvents;
  16. struct /* coclass */ MMap;
  17.  
  18. //
  19. // Smart pointer typedef declarations
  20. //
  21.  
  22. _COM_SMARTPTR_TYPEDEF(_DMMap, __uuidof(IDispatch));
  23. _COM_SMARTPTR_TYPEDEF(_DMMapEvents, __uuidof(IDispatch));
  24.  
  25. //
  26. // Type library items
  27. //
  28.  
  29. enum enumMoveMapMode
  30. {
  31. Stationary = 0,
  32. Floating = 1
  33. };
  34.  
  35. enum enumBevelStyle
  36. {
  37. BevelNone = 0,
  38. BevelRaised = 1,
  39. BevelLowered = 2
  40. };
  41.  
  42. enum enumObjectSymbol
  43. {
  44. SymbolWaypoint = 0,
  45. SymbolNavAid = 1,
  46. SymbolAirport = 2,
  47. SymbolAirplane = 3,
  48. SymbolPicture = 4,
  49. SymbolUserDefined = 5
  50. };
  51.  
  52. enum enumObjectStyle
  53. {
  54. Transparent = 0,
  55. Opaque = 1
  56. };
  57.  
  58. enum enumLineStyle
  59. {
  60. Solid = 0,
  61. Dash = 1,
  62. Dot = 2,
  63. DashDot = 3,
  64. DashDotDot = 4
  65. };
  66.  
  67. enum enumWaypointLineStyle
  68. {
  69. WaypointLineNone = 0,
  70. WaypointLineSolid = 1,
  71. WaypointLineDash = 2,
  72. WaypointLineDot = 3,
  73. WaypointLineDashDot = 4,
  74. WaypointLineDashDotDot = 5
  75. };
  76.  
  77. enum enumObjectFOVStyle
  78. {
  79. NoFOV = 0,
  80. BoundedFOV = 1,
  81. ShadedFOV = 2
  82. };
  83.  
  84. enum enumGridStyle
  85. {
  86. NoGrid = 0,
  87. HorizontalGrid = 1,
  88. VerticalGrid = 2,
  89. BothGrid = 3
  90. };
  91.  
  92. enum enumCaptionOrientation
  93. {
  94. HorizontalCaption = 0,
  95. VerticalLeftCaption = 1,
  96. VerticalRightCaption = 2
  97. };
  98.  
  99. struct __declspec(uuid("d5f63c22-b3d3-11d0-b8f0-0020af344e0a"))
  100. _DMMap : IDispatch
  101. {
  102. //
  103. // Property data
  104. //
  105.  
  106. __declspec(property(get=GetMapNorth,put=PutMapNorth))
  107. double MapNorth;
  108. __declspec(property(get=GetMapSouth,put=PutMapSouth))
  109. double MapSouth;
  110. __declspec(property(get=GetMapEast,put=PutMapEast))
  111. double MapEast;
  112. __declspec(property(get=GetMapWest,put=PutMapWest))
  113. double MapWest;
  114. __declspec(property(get=GetMappingMode,put=PutMappingMode))
  115. enum enumMoveMapMode MappingMode;
  116. __declspec(property(get=GetMaps,put=PutMaps))
  117. short Maps;
  118. __declspec(property(get=GetMapID,put=PutMapID))
  119. short MapID;
  120. __declspec(property(get=GetCaption,put=PutCaption))
  121. _bstr_t Caption;
  122. __declspec(property(get=GetCaptionColor,put=PutCaptionColor))
  123. OLE_COLOR CaptionColor;
  124. __declspec(property(get=GetCaptionID,put=PutCaptionID))
  125. short CaptionID;
  126. __declspec(property(get=GetCaptionFontID,put=PutCaptionFontID))
  127. short CaptionFontID;
  128. __declspec(property(get=GetCaptions,put=PutCaptions))
  129. short Captions;
  130. __declspec(property(get=GetCaptionX,put=PutCaptionX))
  131. double CaptionX;
  132. __declspec(property(get=GetCaptionY,put=PutCaptionY))
  133. double CaptionY;
  134. __declspec(property(get=GetBackPicture,put=PutBackPicture))
  135. PicturePtr BackPicture;
  136. __declspec(property(get=GetBevelInner,put=PutBevelInner))
  137. enum enumBevelStyle BevelInner;
  138. __declspec(property(get=GetBevelOuter,put=PutBevelOuter))
  139. enum enumBevelStyle BevelOuter;
  140. __declspec(property(get=GetBevelWidth,put=PutBevelWidth))
  141. short BevelWidth;
  142. __declspec(property(get=GetBorderWidth,put=PutBorderWidth))
  143. short BorderWidth;
  144. __declspec(property(get=GetFontName,put=PutFontName))
  145. _bstr_t FontName;
  146. __declspec(property(get=GetFontSize,put=PutFontSize))
  147. float FontSize;
  148. __declspec(property(get=GetFontID,put=PutFontID))
  149. short FontID;
  150. __declspec(property(get=GetFont,put=PutFont))
  151. FontPtr Font;
  152. __declspec(property(get=GetFonts,put=PutFonts))
  153. short Fonts;
  154. __declspec(property(get=GetFontBold,put=PutFontBold))
  155. VARIANT_BOOL FontBold;
  156. __declspec(property(get=GetFontItalic,put=PutFontItalic))
  157. VARIANT_BOOL FontItalic;
  158. __declspec(property(get=GetFontStrikethru,put=PutFontStrikethru))
  159. VARIANT_BOOL FontStrikethru;
  160. __declspec(property(get=GetFontUnderline,put=PutFontUnderline))
  161. VARIANT_BOOL FontUnderline;
  162. __declspec(property(get=GetAutoRedraw,put=PutAutoRedraw))
  163. VARIANT_BOOL AutoRedraw;
  164. __declspec(property(get=GetMapPicture,put=PutMapPicture))
  165. PicturePtr MapPicture;
  166. __declspec(property(get=GetBackColor,put=PutBackColor))
  167. OLE_COLOR BackColor;
  168. __declspec(property(get=GetViewCenterX,put=PutViewCenterX))
  169. double ViewCenterX;
  170. __declspec(property(get=GetViewCenterY,put=PutViewCenterY))
  171. double ViewCenterY;
  172. __declspec(property(get=GetViewRadius,put=PutViewRadius))
  173. double ViewRadius;
  174. __declspec(property(get=GetViews,put=PutViews))
  175. short Views;
  176. __declspec(property(get=GetViewID,put=PutViewID))
  177. short ViewID;
  178. __declspec(property(get=GetObjects,put=PutObjects))
  179. short Objects;
  180. __declspec(property(get=GetObjectID,put=PutObjectID))
  181. short ObjectID;
  182. __declspec(property(get=GetObjectSymbol,put=PutObjectSymbol))
  183. enum enumObjectSymbol ObjectSymbol;
  184. __declspec(property(get=GetObjectColor,put=PutObjectColor))
  185. OLE_COLOR ObjectColor;
  186. __declspec(property(get=GetObjectOrientation,put=PutObjectOrientation))
  187. double ObjectOrientation;
  188. __declspec(property(get=GetObjectShape,put=PutObjectShape))
  189. _bstr_t ObjectShape;
  190. __declspec(property(get=GetObjectCaption,put=PutObjectCaption))
  191. _bstr_t ObjectCaption;
  192. __declspec(property(get=GetObjectScale,put=PutObjectScale))
  193. double ObjectScale;
  194. __declspec(property(get=GetWaypoints,put=PutWaypoints))
  195. short Waypoints;
  196. __declspec(property(get=GetWaypointStyle,put=PutWaypointStyle))
  197. enum enumObjectStyle WaypointStyle;
  198. __declspec(property(get=GetWaypointID,put=PutWaypointID))
  199. short WaypointID;
  200. __declspec(property(get=GetWaypointCaption,put=PutWaypointCaption))
  201. _bstr_t WaypointCaption;
  202. __declspec(property(get=GetWaypointOrientation,put=PutWaypointOrientation))
  203. double WaypointOrientation;
  204. __declspec(property(get=GetWaypointScale,put=PutWaypointScale))
  205. double WaypointScale;
  206. __declspec(property(get=GetWaypointSymbol,put=PutWaypointSymbol))
  207. enum enumObjectSymbol WaypointSymbol;
  208. __declspec(property(get=GetWaypointX,put=PutWaypointX))
  209. double WaypointX;
  210. __declspec(property(get=GetWaypointY,put=PutWaypointY))
  211. double WaypointY;
  212. __declspec(property(get=GetWaypointColor,put=PutWaypointColor))
  213. OLE_COLOR WaypointColor;
  214. __declspec(property(get=GetObjectStyle,put=PutObjectStyle))
  215. enum enumObjectStyle ObjectStyle;
  216. __declspec(property(get=GetObjectX,put=PutObjectX))
  217. double ObjectX;
  218. __declspec(property(get=GetObjectY,put=PutObjectY))
  219. double ObjectY;
  220. __declspec(property(get=GetWaypointLineColor,put=PutWaypointLineColor))
  221. OLE_COLOR WaypointLineColor;
  222. __declspec(property(get=GetWaypointLineStyle,put=PutWaypointLineStyle))
  223. enum enumWaypointLineStyle WaypointLineStyle;
  224. __declspec(property(get=GetObjectBreadTrail,put=PutObjectBreadTrail))
  225. VARIANT_BOOL ObjectBreadTrail;
  226. __declspec(property(get=GetObjectHeading,put=PutObjectHeading))
  227. double ObjectHeading;
  228. __declspec(property(get=GetObjectHeadingLineColor,put=PutObjectHeadingLineColor))
  229. OLE_COLOR ObjectHeadingLineColor;
  230. __declspec(property(get=GetObjectHeadingLineRange,put=PutObjectHeadingLineRange))
  231. double ObjectHeadingLineRange;
  232. __declspec(property(get=GetObjectHeadingLineWidth,put=PutObjectHeadingLineWidth))
  233. short ObjectHeadingLineWidth;
  234. __declspec(property(get=GetObjectHeadingShow,put=PutObjectHeadingShow))
  235. VARIANT_BOOL ObjectHeadingShow;
  236. __declspec(property(get=GetObjectFOVStyle,put=PutObjectFOVStyle))
  237. enum enumObjectFOVStyle ObjectFOVStyle;
  238. __declspec(property(get=GetObjectFOV,put=PutObjectFOV))
  239. double ObjectFOV;
  240. __declspec(property(get=GetObjectFOVLineColor,put=PutObjectFOVLineColor))
  241. OLE_COLOR ObjectFOVLineColor;
  242. __declspec(property(get=GetObjectFOVLineRange,put=PutObjectFOVLineRange))
  243. double ObjectFOVLineRange;
  244. __declspec(property(get=GetObjectFOVLineWidth,put=PutObjectFOVLineWidth))
  245. short ObjectFOVLineWidth;
  246. __declspec(property(get=GetObjectPicture,put=PutObjectPicture))
  247. PicturePtr ObjectPicture;
  248. __declspec(property(get=GetGridStyle,put=PutGridStyle))
  249. enum enumGridStyle GridStyle;
  250. __declspec(property(get=GetGridXDelta,put=PutGridXDelta))
  251. double GridXDelta;
  252. __declspec(property(get=GetGridYDelta,put=PutGridYDelta))
  253. double GridYDelta;
  254. __declspec(property(get=GetGridColor,put=PutGridColor))
  255. OLE_COLOR GridColor;
  256. __declspec(property(get=GetViewObjectID,put=PutViewObjectID))
  257. short ViewObjectID;
  258. __declspec(property(get=GetWaypointLineWidth,put=PutWaypointLineWidth))
  259. short WaypointLineWidth;
  260. __declspec(property(get=GetGridLineWidth,put=PutGridLineWidth))
  261. short GridLineWidth;
  262. __declspec(property(get=GetGridLineStyle,put=PutGridLineStyle))
  263. enum enumLineStyle GridLineStyle;
  264. __declspec(property(get=GetGridRefY,put=PutGridRefY))
  265. double GridRefY;
  266. __declspec(property(get=GetGridRefX,put=PutGridRefX))
  267. double GridRefX;
  268. __declspec(property(get=GetObjectZ,put=PutObjectZ))
  269. double ObjectZ;
  270. __declspec(property(get=GetWaypointZ,put=PutWaypointZ))
  271. double WaypointZ;
  272. __declspec(property(get=GetWaypointShape,put=PutWaypointShape))
  273. _bstr_t WaypointShape;
  274. __declspec(property(get=GetWaypointPicture,put=PutWaypointPicture))
  275. PicturePtr WaypointPicture;
  276. __declspec(property(get=GetZoomEnabled,put=PutZoomEnabled))
  277. VARIANT_BOOL ZoomEnabled;
  278. __declspec(property(get=GetPanEnabled,put=PutPanEnabled))
  279. VARIANT_BOOL PanEnabled;
  280. __declspec(property(get=GetCaptionOrientation,put=PutCaptionOrientation))
  281. enum enumCaptionOrientation CaptionOrientation;
  282. __declspec(property(get=GetOutline,put=PutOutline))
  283. VARIANT_BOOL Outline;
  284. __declspec(property(get=GetOutlineTitle,put=PutOutlineTitle))
  285. _bstr_t OutlineTitle;
  286. __declspec(property(get=GetOutlineColor,put=PutOutlineColor))
  287. OLE_COLOR OutlineColor;
  288. __declspec(property(get=GetOutlineWidth,put=PutOutlineWidth))
  289. short OutlineWidth;
  290. __declspec(property(get=GetOutlineAlign,put=PutOutlineAlign))
  291. short OutlineAlign;
  292. __declspec(property(get=GetEnabled,put=PutEnabled))
  293. VARIANT_BOOL Enabled;
  294. __declspec(property(get=GetSingleBuffer,put=PutSingleBuffer))
  295. VARIANT_BOOL SingleBuffer;
  296. __declspec(property(get=GetFocusOutline,put=PutFocusOutline))
  297. VARIANT_BOOL FocusOutline;
  298. __declspec(property(get=GetConfiguration,put=PutConfiguration))
  299. _bstr_t Configuration;
  300.  
  301. //
  302. // Wrapper methods for error-handling
  303. //
  304.  
  305. // Methods:
  306. HRESULT Redraw ( );
  307. HRESULT RedrawStatic ( );
  308. HRESULT ShowPropertyPage ( );
  309. HRESULT SetWaypointData (
  310. const _variant_t & array );
  311. HRESULT SetPositionData (
  312. short ObjectID,
  313. double X,
  314. double Y,
  315. double Z );
  316. HRESULT AboutBox ( );
  317.  
  318. // Properties:
  319. double GetMapNorth ( );
  320. void PutMapNorth ( double _val );
  321. double GetMapSouth ( );
  322. void PutMapSouth ( double _val );
  323. double GetMapEast ( );
  324. void PutMapEast ( double _val );
  325. double GetMapWest ( );
  326. void PutMapWest ( double _val );
  327. enum enumMoveMapMode GetMappingMode ( );
  328. void PutMappingMode ( enum enumMoveMapMode _val );
  329. short GetMaps ( );
  330. void PutMaps ( short _val );
  331. short GetMapID ( );
  332. void PutMapID ( short _val );
  333. _bstr_t GetCaption ( );
  334. void PutCaption ( _bstr_t _val );
  335. OLE_COLOR GetCaptionColor ( );
  336. void PutCaptionColor ( OLE_COLOR _val );
  337. short GetCaptionID ( );
  338. void PutCaptionID ( short _val );
  339. short GetCaptionFontID ( );
  340. void PutCaptionFontID ( short _val );
  341. short GetCaptions ( );
  342. void PutCaptions ( short _val );
  343. double GetCaptionX ( );
  344. void PutCaptionX ( double _val );
  345. double GetCaptionY ( );
  346. void PutCaptionY ( double _val );
  347. PicturePtr GetBackPicture ( );
  348. void PutBackPicture ( struct Picture * _val );
  349. enum enumBevelStyle GetBevelInner ( );
  350. void PutBevelInner ( enum enumBevelStyle _val );
  351. enum enumBevelStyle GetBevelOuter ( );
  352. void PutBevelOuter ( enum enumBevelStyle _val );
  353. short GetBevelWidth ( );
  354. void PutBevelWidth ( short _val );
  355. short GetBorderWidth ( );
  356. void PutBorderWidth ( short _val );
  357. _bstr_t GetFontName ( );
  358. void PutFontName ( _bstr_t _val );
  359. float GetFontSize ( );
  360. void PutFontSize ( float _val );
  361. short GetFontID ( );
  362. void PutFontID ( short _val );
  363. FontPtr GetFont ( );
  364. void PutFont ( struct Font * _val );
  365. short GetFonts ( );
  366. void PutFonts ( short _val );
  367. VARIANT_BOOL GetFontBold ( );
  368. void PutFontBold ( VARIANT_BOOL _val );
  369. VARIANT_BOOL GetFontItalic ( );
  370. void PutFontItalic ( VARIANT_BOOL _val );
  371. VARIANT_BOOL GetFontStrikethru ( );
  372. void PutFontStrikethru ( VARIANT_BOOL _val );
  373. VARIANT_BOOL GetFontUnderline ( );
  374. void PutFontUnderline ( VARIANT_BOOL _val );
  375. VARIANT_BOOL GetAutoRedraw ( );
  376. void PutAutoRedraw ( VARIANT_BOOL _val );
  377. PicturePtr GetMapPicture ( );
  378. void PutMapPicture ( struct Picture * _val );
  379. OLE_COLOR GetBackColor ( );
  380. void PutBackColor ( OLE_COLOR _val );
  381. double GetViewCenterX ( );
  382. void PutViewCenterX ( double _val );
  383. double GetViewCenterY ( );
  384. void PutViewCenterY ( double _val );
  385. double GetViewRadius ( );
  386. void PutViewRadius ( double _val );
  387. short GetViews ( );
  388. void PutViews ( short _val );
  389. short GetViewID ( );
  390. void PutViewID ( short _val );
  391. short GetObjects ( );
  392. void PutObjects ( short _val );
  393. short GetObjectID ( );
  394. void PutObjectID ( short _val );
  395. enum enumObjectSymbol GetObjectSymbol ( );
  396. void PutObjectSymbol ( enum enumObjectSymbol _val );
  397. OLE_COLOR GetObjectColor ( );
  398. void PutObjectColor ( OLE_COLOR _val );
  399. double GetObjectOrientation ( );
  400. void PutObjectOrientation ( double _val );
  401. _bstr_t GetObjectShape ( );
  402. void PutObjectShape ( _bstr_t _val );
  403. _bstr_t GetObjectCaption ( );
  404. void PutObjectCaption ( _bstr_t _val );
  405. double GetObjectScale ( );
  406. void PutObjectScale ( double _val );
  407. short GetWaypoints ( );
  408. void PutWaypoints ( short _val );
  409. enum enumObjectStyle GetWaypointStyle ( );
  410. void PutWaypointStyle ( enum enumObjectStyle _val );
  411. short GetWaypointID ( );
  412. void PutWaypointID ( short _val );
  413. _bstr_t GetWaypointCaption ( );
  414. void PutWaypointCaption ( _bstr_t _val );
  415. double GetWaypointOrientation ( );
  416. void PutWaypointOrientation ( double _val );
  417. double GetWaypointScale ( );
  418. void PutWaypointScale ( double _val );
  419. enum enumObjectSymbol GetWaypointSymbol ( );
  420. void PutWaypointSymbol ( enum enumObjectSymbol _val );
  421. double GetWaypointX ( );
  422. void PutWaypointX ( double _val );
  423. double GetWaypointY ( );
  424. void PutWaypointY ( double _val );
  425. OLE_COLOR GetWaypointColor ( );
  426. void PutWaypointColor ( OLE_COLOR _val );
  427. enum enumObjectStyle GetObjectStyle ( );
  428. void PutObjectStyle ( enum enumObjectStyle _val );
  429. double GetObjectX ( );
  430. void PutObjectX ( double _val );
  431. double GetObjectY ( );
  432. void PutObjectY ( double _val );
  433. OLE_COLOR GetWaypointLineColor ( );
  434. void PutWaypointLineColor ( OLE_COLOR _val );
  435. enum enumWaypointLineStyle GetWaypointLineStyle ( );
  436. void PutWaypointLineStyle ( enum enumWaypointLineStyle _val );
  437. VARIANT_BOOL GetObjectBreadTrail ( );
  438. void PutObjectBreadTrail ( VARIANT_BOOL _val );
  439. double GetObjectHeading ( );
  440. void PutObjectHeading ( double _val );
  441. OLE_COLOR GetObjectHeadingLineColor ( );
  442. void PutObjectHeadingLineColor ( OLE_COLOR _val );
  443. double GetObjectHeadingLineRange ( );
  444. void PutObjectHeadingLineRange ( double _val );
  445. short GetObjectHeadingLineWidth ( );
  446. void PutObjectHeadingLineWidth ( short _val );
  447. VARIANT_BOOL GetObjectHeadingShow ( );
  448. void PutObjectHeadingShow ( VARIANT_BOOL _val );
  449. enum enumObjectFOVStyle GetObjectFOVStyle ( );
  450. void PutObjectFOVStyle ( enum enumObjectFOVStyle _val );
  451. double GetObjectFOV ( );
  452. void PutObjectFOV ( double _val );
  453. OLE_COLOR GetObjectFOVLineColor ( );
  454. void PutObjectFOVLineColor ( OLE_COLOR _val );
  455. double GetObjectFOVLineRange ( );
  456. void PutObjectFOVLineRange ( double _val );
  457. short GetObjectFOVLineWidth ( );
  458. void PutObjectFOVLineWidth ( short _val );
  459. PicturePtr GetObjectPicture ( );
  460. void PutObjectPicture ( struct Picture * _val );
  461. enum enumGridStyle GetGridStyle ( );
  462. void PutGridStyle ( enum enumGridStyle _val );
  463. double GetGridXDelta ( );
  464. void PutGridXDelta ( double _val );
  465. double GetGridYDelta ( );
  466. void PutGridYDelta ( double _val );
  467. OLE_COLOR GetGridColor ( );
  468. void PutGridColor ( OLE_COLOR _val );
  469. short GetViewObjectID ( );
  470. void PutViewObjectID ( short _val );
  471. short GetWaypointLineWidth ( );
  472. void PutWaypointLineWidth ( short _val );
  473. short GetGridLineWidth ( );
  474. void PutGridLineWidth ( short _val );
  475. enum enumLineStyle GetGridLineStyle ( );
  476. void PutGridLineStyle ( enum enumLineStyle _val );
  477. double GetGridRefY ( );
  478. void PutGridRefY ( double _val );
  479. double GetGridRefX ( );
  480. void PutGridRefX ( double _val );
  481. double GetObjectZ ( );
  482. void PutObjectZ ( double _val );
  483. double GetWaypointZ ( );
  484. void PutWaypointZ ( double _val );
  485. _bstr_t GetWaypointShape ( );
  486. void PutWaypointShape ( _bstr_t _val );
  487. PicturePtr GetWaypointPicture ( );
  488. void PutWaypointPicture ( struct Picture * _val );
  489. VARIANT_BOOL GetZoomEnabled ( );
  490. void PutZoomEnabled ( VARIANT_BOOL _val );
  491. VARIANT_BOOL GetPanEnabled ( );
  492. void PutPanEnabled ( VARIANT_BOOL _val );
  493. enum enumCaptionOrientation GetCaptionOrientation ( );
  494. void PutCaptionOrientation ( enum enumCaptionOrientation _val );
  495. VARIANT_BOOL GetOutline ( );
  496. void PutOutline ( VARIANT_BOOL _val );
  497. _bstr_t GetOutlineTitle ( );
  498. void PutOutlineTitle ( _bstr_t _val );
  499. OLE_COLOR GetOutlineColor ( );
  500. void PutOutlineColor ( OLE_COLOR _val );
  501. short GetOutlineWidth ( );
  502. void PutOutlineWidth ( short _val );
  503. short GetOutlineAlign ( );
  504. void PutOutlineAlign ( short _val );
  505. VARIANT_BOOL GetEnabled ( );
  506. void PutEnabled ( VARIANT_BOOL _val );
  507. VARIANT_BOOL GetSingleBuffer ( );
  508. void PutSingleBuffer ( VARIANT_BOOL _val );
  509. VARIANT_BOOL GetFocusOutline ( );
  510. void PutFocusOutline ( VARIANT_BOOL _val );
  511. _bstr_t GetConfiguration ( );
  512. void PutConfiguration ( _bstr_t _val );
  513. };
  514.  
  515. struct __declspec(uuid("d5f63c23-b3d3-11d0-b8f0-0020af344e0a"))
  516. _DMMapEvents : IDispatch
  517. {
  518. //
  519. // Wrapper methods for error-handling
  520. //
  521.  
  522. // Methods:
  523. HRESULT MovePosition (
  524. double X,
  525. double Y );
  526. HRESULT Click ( );
  527. HRESULT DblClick ( );
  528. HRESULT KeyDown (
  529. short * KeyCode,
  530. short Shift );
  531. HRESULT KeyPress (
  532. short * KeyAscii );
  533. HRESULT KeyUp (
  534. short * KeyCode,
  535. short Shift );
  536. HRESULT MouseDown (
  537. short Button,
  538. short Shift,
  539. OLE_XPOS_PIXELS X,
  540. OLE_YPOS_PIXELS Y );
  541. HRESULT MouseMove (
  542. short Button,
  543. short Shift,
  544. OLE_XPOS_PIXELS X,
  545. OLE_YPOS_PIXELS Y );
  546. HRESULT MouseUp (
  547. short Button,
  548. short Shift,
  549. OLE_XPOS_PIXELS X,
  550. OLE_YPOS_PIXELS Y );
  551. HRESULT ClickPosition (
  552. short ObjectID,
  553. double X,
  554. double Y );
  555. };
  556.  
  557. struct __declspec(uuid("d5f63c24-b3d3-11d0-b8f0-0020af344e0a"))
  558. MMap;
  559. // [ default ] dispinterface _DMMap
  560. // [ default, source ] dispinterface _DMMapEvents
  561.  
  562. //
  563. // Named GUID constants initializations
  564. //
  565.  
  566. extern "C" const GUID __declspec(selectany) LIBID_MMAPLib =
  567. {0xd5f63c21,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  568. extern "C" const GUID __declspec(selectany) DIID__DMMap =
  569. {0xd5f63c22,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  570. extern "C" const GUID __declspec(selectany) DIID__DMMapEvents =
  571. {0xd5f63c23,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  572. extern "C" const GUID __declspec(selectany) CLSID_MMap =
  573. {0xd5f63c24,0xb3d3,0x11d0,{0xb8,0xf0,0x00,0x20,0xaf,0x34,0x4e,0x0a}};
  574.  
  575. //
  576. // Wrapper method implementations
  577. //
  578.  
  579. #include "MMap.tli"
  580.  
  581. } // namespace MMAPLib
  582.  
  583. #pragma pack(pop)
  584.  
  585.  
  586.  
  587.  
  588.  
  589. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  590.  
  591. /************************************************/
  592. This is my image.cpp file
  593.  
  594. /************************************************/
  595.  
  596.  
  597. //
  598. #import "c:\WINNT\system32\MMap.ocx" \
  599. named_guids LIBID_MMAPLib,DIID_DMMap,DIID_DMMapEvents,CLSID_MMap \
  600. no_namespace MMAPLib
  601.  
  602. #include "stdafx.h"
  603. #include "image.h"
  604. #include <windows.h>
  605. #include <winerror.h>
  606. #include <stdio.h>
  607. #include <iostream>
  608. #include <assert.h>
  609. #include <cassert>
  610.  
  611.  
  612. void main()
  613. {
  614.  
  615.  
  616. CoInitialize( NULL);
  617.  
  618. _DMMap* pMP = 0;
  619. HRESULT hr = CoCreateInstance( __uuidof(MMap),//class identifier of the object
  620. NULL,
  621. CLSCTX_ALL,// context for running executable code
  622. DIID__DMMap,//reference to the identifier of the inerface
  623. reinterpret_cast <void**>(&pMP));//interface pointer requested in riid
  624. assert(SUCCEEDED(hr));
  625. hr = pMP->GetMapID();
  626. hr = pMP->GetMapNorth();
  627. hr = pMP->GetMapEast();
  628. hr = pMP->GetMapWest();
  629. hr = pMP->GetMapSouth();
  630. assert(SUCCEEDED(hr));
  631. printf("reading the activeX control file ");
  632. pMP ->Release();
  633.  
  634. CoUninitialize();
  635.  
  636. }
  637.  
  638.  
  639. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  640.  
  641.  
  642. /******************************************************/
  643. This is my image.h file
  644.  
  645. /*********************************************************/
  646.  
  647. #include <windows.h>
  648. #include <iostream.h>
  649.  
  650.  
  651.  
  652. class _DMMap
  653. {
  654. public:
  655. _DMMap();
  656. double GetMapID();
  657. void PutMapID(double);
  658. double GetMapEast();
  659. void PutMapEast(double);
  660. double GetMapWest();
  661. void PutMapWest(double);
  662. double GetMapNorth();
  663. void PutMapNorth(double);
  664. double GetMapSouth();
  665. void PutMapSouth(double);
  666. double Release();
  667. ~_DMMap();
  668.  
  669. };
  670. _DMMap DIID__DMMap;
  671.  
  672. class _DMMapEvents
  673. {
  674. public:
  675. HRESULT MovePosition ( double X,double Y );
  676. HRESULT Click ( );
  677. HRESULT DblClick ( );
  678.  
  679. };
  680. _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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC