Source code of Windows XP (NT5)
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.

386 lines
13 KiB

  1. //+-------------------------------------------------------------------
  2. // File: testsrv.hxx
  3. //
  4. // Contents: CTestEmbedCF and CTestEmbed object declarations, other
  5. // miscellaneous tidbits.
  6. //
  7. // History: 24-Nov-92 DeanE Created
  8. // 31-Dec-93 ErikGav Chicago port
  9. //---------------------------------------------------------------------
  10. #ifndef __TESTSRV_HXX__
  11. #define __TESTSRV_HXX__
  12. #include <com.hxx>
  13. #define LOG_ABORT -1
  14. #define LOG_PASS 1
  15. #define LOG_FAIL 0
  16. // Application Window messages
  17. #define WM_RUNTEST (WM_USER + 1)
  18. #define WM_REPORT (WM_USER + 2)
  19. // WM_REPORT wParam codes
  20. #define MB_SHOWVERB 0x0001
  21. #define MB_PRIMVERB 0x0002
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Function: operator new, public
  25. //
  26. // Synopsis: Global operator new which uses CoTaskMemAlloc
  27. //
  28. // Arguments: [size] -- Size of the memory to allocate.
  29. //
  30. // Returns: A pointer to the allocated memory. Is *NOT* initialized to 0!
  31. //
  32. //----------------------------------------------------------------------------
  33. inline void* __cdecl
  34. operator new (size_t size)
  35. {
  36. return(CoTaskMemAlloc(size));
  37. }
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Function: operator delete
  41. //
  42. // Synopsis: Free a block of memory using CoTaskMemFree
  43. //
  44. // Arguments: [lpv] - block to free.
  45. //
  46. //--------------------------------------------------------------------------
  47. inline void __cdecl operator delete(void FAR* lpv)
  48. {
  49. CoTaskMemFree(lpv);
  50. }
  51. // Global variables
  52. extern HWND g_hwndMain;
  53. // Forward declarations
  54. class FAR CDataObject;
  55. class FAR CPersistStorage;
  56. class FAR COleObject;
  57. class FAR CTestEmbedCF;
  58. //+-------------------------------------------------------------------
  59. // Class: CTestServerApp
  60. //
  61. // Synopsis: Class that holds application-wide data and methods
  62. //
  63. // Methods: InitApp
  64. // CloseApp
  65. // GetEmbeddedFlag
  66. //
  67. // History: 17-Dec-92 DeanE Created
  68. //--------------------------------------------------------------------
  69. class FAR CTestServerApp
  70. {
  71. public:
  72. // Constructor/Destructor
  73. CTestServerApp();
  74. ~CTestServerApp();
  75. SCODE InitApp (LPSTR lpszCmdline);
  76. SCODE CloseApp (void);
  77. BOOL GetEmbeddedFlag (void);
  78. ULONG IncEmbeddedCount(void);
  79. ULONG DecEmbeddedCount(void);
  80. private:
  81. IClassFactory *_pteClassFactory;
  82. ULONG _cEmbeddedObjs; // Count of embedded objects this server
  83. // is controlling now
  84. DWORD _dwRegId; // OLE registration ID
  85. BOOL _fRegistered; // TRUE if srv was registered w/OLE
  86. BOOL _fInitialized; // TRUE if OleInitialize was OK
  87. BOOL _fEmbedded; // TRUE if OLE started us at the request
  88. // of an embedded obj in a container app
  89. };
  90. //+-------------------------------------------------------------------
  91. // Class: CTestEmbedCF
  92. //
  93. // Synopsis: Class Factory for CTestEmbed object type
  94. //
  95. // Methods: QueryInterface - IUnknown
  96. // AddRef - IUnknown
  97. // Release - IUnknown
  98. // CreateInstance - IClassFactory
  99. // LockServer - IClassFactory
  100. //
  101. // History: 24-Nov-92 DeanE Created
  102. //--------------------------------------------------------------------
  103. class CTestEmbedCF : public IClassFactory
  104. {
  105. public:
  106. // Constructor/Destructor
  107. CTestEmbedCF(CTestServerApp *ptsaServer);
  108. ~CTestEmbedCF();
  109. static IClassFactory FAR *Create(CTestServerApp *ptsaServer);
  110. // IUnknown
  111. STDMETHODIMP QueryInterface (REFIID iid, void FAR * FAR *ppv);
  112. STDMETHODIMP_(ULONG) AddRef (void);
  113. STDMETHODIMP_(ULONG) Release (void);
  114. // IClassFactory
  115. STDMETHODIMP CreateInstance (IUnknown FAR *pUnkOuter,
  116. REFIID iidInterface,
  117. void FAR * FAR *ppv);
  118. STDMETHODIMP LockServer (BOOL fLock);
  119. private:
  120. ULONG _cRef; // Reference count on this object
  121. CTestServerApp *_ptsaServer; // Controlling server app
  122. };
  123. //+-------------------------------------------------------------------
  124. // Class: CTestEmbed
  125. //
  126. // Synopsis: CTestEmbed (one instance per object)
  127. //
  128. // Methods: QueryInterface IUnknown
  129. // AddRef IUnknown
  130. // Release IUnknown
  131. // InitObject
  132. //
  133. // History: 24-Nov-92 DeanE Created
  134. //--------------------------------------------------------------------
  135. class CTestEmbed : public IUnknown
  136. {
  137. public:
  138. // Constructor/Destructor
  139. CTestEmbed();
  140. ~CTestEmbed();
  141. // IUnknown
  142. STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv);
  143. STDMETHODIMP_(ULONG) AddRef (void);
  144. STDMETHODIMP_(ULONG) Release (void);
  145. SCODE InitObject (CTestServerApp *ptsaServer, HWND hwnd);
  146. SCODE GetWindow (HWND *phwnd);
  147. private:
  148. ULONG _cRef; // Reference counter
  149. CTestServerApp *_ptsaServer; // Server "holding" this object
  150. CDataObject *_pDataObject; // Points to object's IDataObject
  151. COleObject *_pOleObject; // Points to object's IOleObject
  152. CPersistStorage *_pPersStg; // Points to object's IPersistStorage
  153. HWND _hwnd; // Window handle for this object
  154. };
  155. //+-------------------------------------------------------------------
  156. // Class: CDataObject
  157. //
  158. // Synopsis: Test class CDataObject
  159. //
  160. // Methods: QueryInterface IUnknown
  161. // AddRef IUnknown
  162. // Release IUnknown
  163. // GetData IDataObject
  164. // GetDataHere IDataObject
  165. // QueryGetData IDataObject
  166. // GetCanonicalFormatEtc IDataObject
  167. // SetData IDataObject
  168. // EnumFormatEtc IDataObject
  169. // DAdvise IDataObject
  170. // DUnadvise IDataObject
  171. // EnumDAdvise IDataObject
  172. //
  173. // History: 24-Nov-92 DeanE Created
  174. //--------------------------------------------------------------------
  175. class FAR CDataObject : public IDataObject
  176. {
  177. public:
  178. // Constructor/Destructor
  179. CDataObject(CTestEmbed *pteObject);
  180. ~CDataObject();
  181. // IUnknown - Everyone inherits from this
  182. STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv);
  183. STDMETHODIMP_(ULONG) AddRef (void);
  184. STDMETHODIMP_(ULONG) Release (void);
  185. // IDataObject
  186. STDMETHODIMP GetData (LPFORMATETC pformatetcIn,
  187. LPSTGMEDIUM pmedium);
  188. STDMETHODIMP GetDataHere (LPFORMATETC pformatetc,
  189. LPSTGMEDIUM pmedium);
  190. STDMETHODIMP QueryGetData (LPFORMATETC pformatetc);
  191. STDMETHODIMP GetCanonicalFormatEtc(
  192. LPFORMATETC pformatetc,
  193. LPFORMATETC pformatetcOut);
  194. STDMETHODIMP SetData (LPFORMATETC pformatetc,
  195. STGMEDIUM FAR *pmedium,
  196. BOOL fRelease);
  197. STDMETHODIMP EnumFormatEtc (DWORD dwDirection,
  198. LPENUMFORMATETC FAR *ppenmFormatEtc);
  199. STDMETHODIMP DAdvise (FORMATETC FAR *pFormatetc,
  200. DWORD advf,
  201. LPADVISESINK pAdvSink,
  202. DWORD FAR *pdwConnection);
  203. STDMETHODIMP DUnadvise (DWORD dwConnection);
  204. STDMETHODIMP EnumDAdvise (LPENUMSTATDATA FAR *ppenmAdvise);
  205. private:
  206. ULONG _cRef; // Reference count
  207. IDataAdviseHolder FAR *_pDAHolder; // Advise Holder
  208. CTestEmbed *_pteObject; // Object we're associated with
  209. };
  210. //+-------------------------------------------------------------------
  211. // Class: COleObject
  212. //
  213. // Synopsis: COleObject implements the IOleObject interface for OLE
  214. // objects within the server. There will be one instantiation
  215. // per OLE object.
  216. //
  217. // Methods: QueryInterface IUnknown
  218. // AddRef IUnknown
  219. // Release IUnknown
  220. // SetClientSite IOleObject
  221. // GetClientSite IOleObject
  222. // SetHostNames IOleObject
  223. // Close IOleObject
  224. // SetMoniker IOleObject
  225. // GetMoniker IOleObject
  226. // InitFromData IOleObject
  227. // GetClipboardData IOleObject
  228. // DoVerb IOleObject
  229. // EnumVerbs IOleObject
  230. // Update IOleObject
  231. // IsUpToDate IOleObject
  232. // GetUserType IOleObject
  233. // SetExtent IOleObject
  234. // GetExtent IOleObject
  235. // Advise IOleObject
  236. // Unadvise IOleObject
  237. // EnumAdvise IOleObject
  238. // GetMiscStatus IOleObject
  239. // SetColorScheme IOleObject
  240. //
  241. // History: 17-Dec-92 DeanE Created
  242. //--------------------------------------------------------------------
  243. class FAR COleObject : public IOleObject
  244. {
  245. public:
  246. // Constructor/Destructor
  247. COleObject(CTestEmbed *pteObject);
  248. ~COleObject();
  249. // IUnknown
  250. STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv);
  251. STDMETHODIMP_(ULONG) AddRef (void);
  252. STDMETHODIMP_(ULONG) Release (void);
  253. // IOleObject
  254. STDMETHODIMP SetClientSite (LPOLECLIENTSITE pClientSite);
  255. STDMETHODIMP GetClientSite (LPOLECLIENTSITE FAR *ppClientSite);
  256. STDMETHODIMP SetHostNames (LPCWSTR szContainerApp, LPCWSTR szContainerObj);
  257. STDMETHODIMP Close (DWORD dwSaveOption);
  258. STDMETHODIMP SetMoniker (DWORD dwWhichMoniker, LPMONIKER pmk);
  259. STDMETHODIMP GetMoniker (DWORD dwAssign,
  260. DWORD dwWhichMoniker,
  261. LPMONIKER FAR *ppmk);
  262. STDMETHODIMP InitFromData (LPDATAOBJECT pDataObject,
  263. BOOL fCreation,
  264. DWORD dwReserved);
  265. STDMETHODIMP GetClipboardData(
  266. DWORD dwReserved,
  267. LPDATAOBJECT FAR *ppDataObject);
  268. STDMETHODIMP DoVerb (LONG iVerb,
  269. LPMSG pMsg,
  270. LPOLECLIENTSITE pActiveSite,
  271. LONG lReserved,
  272. HWND hwndParent,
  273. LPCRECT lprcPosRect);
  274. STDMETHODIMP EnumVerbs (IEnumOLEVERB FAR* FAR* ppenmOleVerb);
  275. STDMETHODIMP Update (void);
  276. STDMETHODIMP IsUpToDate (void);
  277. STDMETHODIMP GetUserClassID(CLSID FAR* pClsid);
  278. STDMETHODIMP GetUserType (DWORD dwFormOfType, LPWSTR FAR *pszUserType);
  279. STDMETHODIMP SetExtent (DWORD dwDrawAspect, LPSIZEL lpsizel);
  280. STDMETHODIMP GetExtent (DWORD dwDrawAspect, LPSIZEL lpsizel);
  281. STDMETHODIMP Advise (IAdviseSink FAR *pAdvSink,
  282. DWORD FAR *pdwConnection);
  283. STDMETHODIMP Unadvise (DWORD dwConnection);
  284. STDMETHODIMP EnumAdvise (LPENUMSTATDATA FAR *ppenmAdvise);
  285. STDMETHODIMP GetMiscStatus (DWORD dwAspect, DWORD FAR *pdwStatus);
  286. STDMETHODIMP SetColorScheme(LPLOGPALETTE lpLogpal);
  287. private:
  288. ULONG _cRef; // Reference count
  289. IOleAdviseHolder FAR *_pOAHolder; // Advise Holder
  290. IOleClientSite FAR *_pocs; // This objects client site
  291. CTestEmbed *_pteObject; // Object we're associated with
  292. IMoniker * _pmkContainer;
  293. };
  294. //+-------------------------------------------------------------------
  295. // Class: CPersistStorage
  296. //
  297. // Synopsis: Test class CPersistStorage
  298. //
  299. // Methods: QueryInterface IUnknown
  300. // AddRef IUnknown
  301. // Release IUnknown
  302. // GetClassId IPersist
  303. // IsDirty IPersistStorage
  304. // InitNew IPersistStorage
  305. // Load IPersistStorage
  306. // Save IPersistStorage
  307. // SaveCompleted IPersistStorage
  308. //
  309. // History: 24-Nov-92 DeanE Created
  310. //--------------------------------------------------------------------
  311. class FAR CPersistStorage : public IPersistStorage
  312. {
  313. public:
  314. // Constructor/Destructor
  315. CPersistStorage(CTestEmbed *pteObject);
  316. ~CPersistStorage();
  317. // IUnknown - Everyone inherits from this
  318. STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv);
  319. STDMETHODIMP_(ULONG) AddRef (void);
  320. STDMETHODIMP_(ULONG) Release (void);
  321. // IPersist - IPersistStorage inherits from this
  322. STDMETHODIMP GetClassID (LPCLSID pClassId);
  323. // IPersistStorage
  324. STDMETHODIMP IsDirty (void);
  325. STDMETHODIMP InitNew (LPSTORAGE pStg);
  326. STDMETHODIMP Load (LPSTORAGE pStg);
  327. STDMETHODIMP Save (LPSTORAGE pStgSave,
  328. BOOL fSameAsLoad);
  329. STDMETHODIMP SaveCompleted (LPSTORAGE pStgSaved);
  330. STDMETHODIMP HandsOffStorage (void);
  331. private:
  332. ULONG _cRef; // Reference count
  333. CTestEmbed *_pteObject; // Object we're associated with
  334. BOOL _fDirty; // TRUE if object is dirty
  335. };
  336. #endif // __TESTSRV_HXX__