Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
5.1 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. inole.h
  5. Abstract:
  6. Master header file for all Inside OLE samples.
  7. --*/
  8. #ifndef _INOLE_H_
  9. #define _INOLE_H_
  10. #define INC_OLE2
  11. #include <windows.h>
  12. #include <ole2.h>
  13. #include <ole2ver.h>
  14. #ifdef INITGUIDS
  15. #include <initguid.h>
  16. #endif
  17. #include <oleauto.h>
  18. #include <olectl.h>
  19. //Types that OLE2.H et. al. leave out
  20. #ifndef PPVOID
  21. typedef LPVOID * PPVOID;
  22. #endif //PPVOID
  23. #ifdef _OLE2_H_ //May not include ole2.h at all times.
  24. #ifndef PPOINTL
  25. typedef POINTL * PPOINTL;
  26. #endif //PPOINTL
  27. #ifndef _WIN32
  28. #ifndef OLECHAR
  29. typedef char OLECHAR;
  30. typedef OLECHAR FAR* LPOLESTR;
  31. typedef const OLECHAR FAR* LPCOLESTR;
  32. #endif //OLECHAR
  33. #endif //_WIN32
  34. #include <tchar.h>
  35. //Useful macros.
  36. #define SETFormatEtc(fe, cf, asp, td, med, li) \
  37. {\
  38. (fe).cfFormat=cf;\
  39. (fe).dwAspect=asp;\
  40. (fe).ptd=td;\
  41. (fe).tymed=med;\
  42. (fe).lindex=li;\
  43. }
  44. #define SETDefFormatEtc(fe, cf, med) \
  45. {\
  46. (fe).cfFormat=cf;\
  47. (fe).dwAspect=DVASPECT_CONTENT;\
  48. (fe).ptd=NULL;\
  49. (fe).tymed=med;\
  50. (fe).lindex=-1;\
  51. }
  52. #define SETRECTL(rcl, l, t, r, b) \
  53. {\
  54. (rcl).left=l;\
  55. (rcl).top=t;\
  56. (rcl).right=r;\
  57. (rcl).bottom=b;\
  58. }
  59. #define SETSIZEL(szl, h, v) \
  60. {\
  61. (szl).cx=h;\
  62. (szl).cy=v;\
  63. }
  64. #define RECTLFROMRECT(rcl, rc)\
  65. {\
  66. (rcl).left=(long)(rc).left;\
  67. (rcl).top=(long)(rc).top;\
  68. (rcl).right=(long)(rc).right;\
  69. (rcl).bottom=(long)(rc).bottom;\
  70. }
  71. #define RECTFROMRECTL(rc, rcl)\
  72. {\
  73. (rc).left=(int)(rcl).left;\
  74. (rc).top=(int)(rcl).top;\
  75. (rc).right=(int)(rcl).right;\
  76. (rc).bottom=(int)(rcl).bottom;\
  77. }
  78. #define POINTLFROMPOINT(ptl, pt) \
  79. { \
  80. (ptl).x=(long)(pt).x; \
  81. (ptl).y=(long)(pt).y; \
  82. }
  83. #define POINTFROMPOINTL(pt, ptl) \
  84. { \
  85. (pt).x=(int)(ptl).x; \
  86. (pt).y=(int)(ptl).y; \
  87. }
  88. //Here's one that should be in windows.h
  89. #define SETPOINT(pt, h, v) \
  90. {\
  91. (pt).x=h;\
  92. (pt).y=v;\
  93. }
  94. #define SETPOINTL(ptl, h, v) \
  95. {\
  96. (ptl).x=h;\
  97. (ptl).y=v;\
  98. }
  99. #endif //_OLE2_H_
  100. //Macros for setting DISPPARAMS structures
  101. #define SETDISPPARAMS(dp, numArgs, pvArgs, numNamed, pNamed) \
  102. {\
  103. (dp).cArgs=numArgs;\
  104. (dp).rgvarg=pvArgs;\
  105. (dp).cNamedArgs=numNamed;\
  106. (dp).rgdispidNamedArgs=pNamed;\
  107. }
  108. #define SETNOPARAMS(dp) SETDISPPARAMS(dp, 0, NULL, 0, NULL)
  109. //Macros for setting EXCEPINFO structures
  110. #define SETEXCEPINFO(ei, excode, src, desc, file, ctx, func, scd) \
  111. {\
  112. (ei).wCode=excode;\
  113. (ei).wReserved=0;\
  114. (ei).bstrSource=src;\
  115. (ei).bstrDescription=desc;\
  116. (ei).bstrHelpFile=file;\
  117. (ei).dwHelpContext=ctx;\
  118. (ei).pvReserved=NULL;\
  119. (ei).pfnDeferredFillIn=func;\
  120. (ei).scode=scd;\
  121. }
  122. #define INITEXCEPINFO(ei) \
  123. SETEXCEPINFO(ei,0,NULL,NULL,NULL,0L,NULL,S_OK)
  124. /*
  125. * State flags for IPersistStorage implementations. These
  126. * are kept here to avoid repeating the code in all samples.
  127. */
  128. typedef enum
  129. {
  130. PSSTATE_UNINIT, //Uninitialized
  131. PSSTATE_SCRIBBLE, //Scribble
  132. PSSTATE_ZOMBIE, //No scribble
  133. PSSTATE_HANDSOFF //Hand-off
  134. } PSSTATE;
  135. /*
  136. * Identifers to describe which persistence model an object
  137. * is using, along with a union type that holds on the the
  138. * appropriate pointers that a client may need.
  139. */
  140. typedef enum
  141. {
  142. PERSIST_UNKNOWN=0,
  143. PERSIST_STORAGE,
  144. PERSIST_STREAM,
  145. PERSIST_STREAMINIT,
  146. PERSIST_FILE
  147. } PERSIST_MODEL;
  148. typedef struct
  149. {
  150. PERSIST_MODEL psModel;
  151. union
  152. {
  153. IPersistStorage *pIPersistStorage;
  154. IPersistStream *pIPersistStream;
  155. IPersistStreamInit *pIPersistStreamInit;
  156. IPersistFile *pIPersistFile;
  157. } pIP;
  158. } PERSISTPOINTER, *PPERSISTPOINTER;
  159. //To identify a storage in which to save, load, or create.
  160. typedef struct
  161. {
  162. PERSIST_MODEL psModel;
  163. union
  164. {
  165. IStorage *pIStorage;
  166. IStream *pIStream;
  167. } pIS;
  168. } STGPOINTER, *PSTGPOINTER;
  169. //Type for an object-destroyed callback
  170. typedef void (*PFNDESTROYED)(void);
  171. //DeleteInterfaceImp calls 'delete' and NULLs the pointer
  172. #define DeleteInterfaceImp(p)\
  173. {\
  174. if (NULL!=p)\
  175. {\
  176. delete p;\
  177. p=NULL;\
  178. }\
  179. }
  180. //ReleaseInterface calls 'Release' and NULLs the pointer
  181. #define ReleaseInterface(p)\
  182. {\
  183. if (NULL!=p)\
  184. {\
  185. p->Release();\
  186. p=NULL;\
  187. }\
  188. }
  189. //OLE Documents Clipboard Formats
  190. #define CFSTR_EMBEDSOURCE TEXT("Embed Source")
  191. #define CFSTR_EMBEDDEDOBJECT TEXT("Embedded Object")
  192. #define CFSTR_LINKSOURCE TEXT("Link Source")
  193. #define CFSTR_CUSTOMLINKSOURCE TEXT("Custom Link Source")
  194. #define CFSTR_OBJECTDESCRIPTOR TEXT("Object Descriptor")
  195. #define CFSTR_LINKSRCDESCRIPTOR TEXT("Link Source Descriptor")
  196. #endif //_INOLE_H_