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.

734 lines
26 KiB

  1. /*************************************************************************
  2. **
  3. ** OLE 2.0 Sample Code
  4. **
  5. ** oleoutl.h
  6. **
  7. ** This file contains file contains data structure defintions,
  8. ** function prototypes, constants, etc. which are common to the
  9. ** server version and the container version of the app.
  10. ** app version of the Outline series of sample applications:
  11. ** Outline -- base version of the app (without OLE functionality)
  12. ** SvrOutl -- OLE 2.0 Server sample app
  13. ** CntrOutl -- OLE 2.0 Containter sample app
  14. **
  15. ** (c) Copyright Microsoft Corp. 1992 - 1993 All Rights Reserved
  16. **
  17. *************************************************************************/
  18. #if !defined( _OLEOUTL_H_ )
  19. #define _OLEOUTL_H_
  20. #ifndef RC_INVOKED
  21. #pragma message ("INCLUDING OLEOUTL.H from " __FILE__)
  22. // make 'different levels of inderection' considered an error
  23. #pragma warning (error:4047)
  24. #endif /* RC_INVOKED */
  25. #if defined( USE_MSGFILTER )
  26. #include "msgfiltr.h"
  27. #endif // USE_MSGFILTER
  28. #include "defguid.h"
  29. /* Defines */
  30. /* OLE2NOTE: these strings should correspond to the strings registered
  31. ** in the registration database.
  32. */
  33. // REVIEW: should load strings from resource file
  34. #if defined( INPLACE_SVR )
  35. #define CLSID_APP CLSID_ISvrOtl
  36. #define FULLUSERTYPENAME "Ole 2.0 In-Place Server Outline"
  37. #define SHORTUSERTYPENAME "Outline" // max 15 chars
  38. #undef APPFILENAMEFILTER
  39. #define APPFILENAMEFILTER "Outline Files (*.OLN)|*.oln|All files (*.*)|*.*|"
  40. #undef DEFEXTENSION
  41. #define DEFEXTENSION "oln" // Default file extension
  42. #endif // INPLACE_SVR
  43. #if defined( INPLACE_CNTR )
  44. #define CLSID_APP CLSID_ICntrOtl
  45. #define FULLUSERTYPENAME "Ole 2.0 In-Place Container Outline"
  46. // #define SHORTUSERTYPENAME "Outline" // max 15 chars
  47. #undef APPFILENAMEFILTER
  48. #define APPFILENAMEFILTER "CntrOutl Files (*.OLC)|*.olc|Outline Files (*.OLN)|*.oln|All files (*.*)|*.*|"
  49. #undef DEFEXTENSION
  50. #define DEFEXTENSION "olc" // Default file extension
  51. #endif // INPLACE_CNTR
  52. #if defined( OLE_SERVER ) && !defined( INPLACE_SVR )
  53. #define CLSID_APP CLSID_SvrOutl
  54. #define FULLUSERTYPENAME "Ole 2.0 Server Sample Outline"
  55. #define SHORTUSERTYPENAME "Outline"
  56. #undef APPFILENAMEFILTER
  57. #define APPFILENAMEFILTER "Outline Files (*.OLN)|*.oln|All files (*.*)|*.*|"
  58. #undef DEFEXTENSION
  59. #define DEFEXTENSION "oln" // Default file extension
  60. #endif // OLE_SERVER && ! INPLACE_SVR
  61. #if defined( OLE_CNTR ) && !defined( INPLACE_CNTR )
  62. #define CLSID_APP CLSID_CntrOutl
  63. #define FULLUSERTYPENAME "Ole 2.0 Container Sample Outline"
  64. // #define SHORTUSERTYPENAME "Outline" // max 15 chars
  65. #undef APPFILENAMEFILTER
  66. #define APPFILENAMEFILTER "CntrOutl Files (*.OLC)|*.olc|Outline Files (*.OLN)|*.oln|All files (*.*)|*.*|"
  67. #undef DEFEXTENSION
  68. #define DEFEXTENSION "olc" // Default file extension
  69. #endif // OLE_CNTR && ! INPLACE_CNTR
  70. // Maximum number of formats offered by IDataObject::GetData/SetData
  71. #define MAXNOFMTS 10
  72. #define MAXNOLINKTYPES 3
  73. #if defined( USE_DRAGDROP )
  74. #define DD_SEL_THRESH HITTESTDELTA // Border threshold to start drag
  75. #define MAX_SEL_ITEMS 0x0080
  76. #endif // USE_DRAGDROP
  77. /* Positions of the various menus */
  78. #define POS_FILEMENU 0
  79. #define POS_EDITMENU 1
  80. #define POS_VIEWMENU 2
  81. #define POS_LINEMENU 3
  82. #define POS_NAMEMENU 4
  83. #define POS_OPTIONSMENU 5
  84. #define POS_DEBUGMENU 6
  85. #define POS_HELPMENU 7
  86. #define POS_OBJECT 11
  87. /* Types */
  88. // Document initialization type
  89. #define DOCTYPE_EMBEDDED 3 // init from an IStorage* of an embedded obj
  90. #define DOCTYPE_FROMSTG 4 // init from an IStorage* with doc bit set
  91. /* Forward type definitions */
  92. typedef struct tagOLEAPP FAR* LPOLEAPP;
  93. typedef struct tagOLEDOC FAR* LPOLEDOC;
  94. /* Flags to control Moniker assignment for OleDoc_GetFullMoniker */
  95. // REVIEW: should use official OLEGETMONIKER type for final version
  96. typedef enum tagGETMONIKERTYPE {
  97. GETMONIKER_ONLYIFTHERE = 1,
  98. GETMONIKER_FORCEASSIGN = 2,
  99. GETMONIKER_UNASSIGN = 3,
  100. GETMONIKER_TEMPFORUSER = 4
  101. } GETMONIKERTYPE;
  102. /* Flags to control direction for drag scrolling */
  103. typedef enum tagSCROLLDIR {
  104. SCROLLDIR_NULL = 0,
  105. SCROLLDIR_UP = 1,
  106. SCROLLDIR_DOWN = 2,
  107. SCROLLDIR_RIGHT = 3, // currently not used
  108. SCROLLDIR_LEFT = 4 // currently not used
  109. } SCROLLDIR;
  110. /*************************************************************************
  111. ** class OLEDOC : OUTLINEDOC
  112. ** OLEDOC is an extention to the base OUTLINEDOC object (structure)
  113. ** that adds common OLE 2.0 functionality used by both the server
  114. ** and container versions. This is an abstract class. You do not
  115. ** instantiate an instance of OLEDOC directly but instead
  116. ** instantiate one of its concrete subclasses: SERVERDOC or
  117. ** CONTAINERDOC. There is one instance of an document
  118. ** object created per document open in the app. The SDI
  119. ** version of the app supports one ServerDoc at a time. The MDI
  120. ** version of the app can manage multiple documents at one time.
  121. ** The OLEDOC class inherits all fields from the OUTLINEDOC class.
  122. ** This inheritance is achieved by including a member variable of
  123. ** type OUTLINEDOC as the first field in the OLEDOC
  124. ** structure. Thus a pointer to an OLEDOC object can be cast to be
  125. ** a pointer to a OUTLINEDOC object.
  126. *************************************************************************/
  127. typedef struct tagOLEDOC {
  128. OUTLINEDOC m_OutlineDoc; // ServerDoc inherits from OutlineDoc
  129. ULONG m_cRef; // total ref count for document
  130. ULONG m_dwStrongExtConn; // total strong connection count
  131. // (from IExternalConnection)
  132. // when this count transitions to 0
  133. // and fLastUnlockCloses==TRUE, then
  134. // IOleObject::Close is called to
  135. // close the document.
  136. #if defined( _DEBUG )
  137. ULONG m_cCntrLock; // total count of LockContainer locks
  138. // (for debugging purposes only)
  139. #endif
  140. LPSTORAGE m_lpStg; // OleDoc must keep its stg open
  141. // even in-memory server doc should
  142. // keep Stg open for low memory save
  143. LPSTREAM m_lpLLStm; // Hold LineList IStream* open for
  144. // low memory save
  145. LPSTREAM m_lpNTStm; // Hold NameTable IStream* open for
  146. // low memory save
  147. BOOL m_fObjIsClosing; // flag to guard recursive close call
  148. BOOL m_fObjIsDestroying; // flag to guard recursiv destroy call
  149. DWORD m_dwRegROT; // key if doc registered as running
  150. LPMONIKER m_lpFileMoniker; // moniker if file-based/untitled doc
  151. BOOL m_fLinkSourceAvail; // can doc offer CF_LINKSOURCE
  152. LPOLEDOC m_lpSrcDocOfCopy; // src doc if doc created for copy
  153. BOOL m_fUpdateEditMenu; // need to update edit menu??
  154. #if defined( USE_DRAGDROP )
  155. DWORD m_dwTimeEnterScrollArea; // time entering scroll region
  156. DWORD m_dwLastScrollDir; // current dir for drag scroll
  157. DWORD m_dwNextScrollTime; // time for next scroll
  158. BOOL m_fRegDragDrop; // is doc registered as drop target?
  159. BOOL m_fLocalDrag; // is doc source of the drag
  160. BOOL m_fLocalDrop; // was doc target of the drop
  161. BOOL m_fCanDropCopy; // is Drag/Drop copy/move possible?
  162. BOOL m_fCanDropLink; // is Drag/Drop link possible?
  163. BOOL m_fDragLeave; // has drag left
  164. BOOL m_fPendingDrag; // LButtonDown--possible drag pending
  165. POINT m_ptButDown; // LButtonDown coordinates
  166. #endif // USE_DRAGDROP
  167. #if defined( INPLACE_SVR ) || defined( INPLACE_CNTR )
  168. BOOL m_fCSHelpMode; // Shift-F1 context help mode
  169. #endif
  170. struct CDocUnknownImpl {
  171. IUnknownVtbl FAR* lpVtbl;
  172. LPOLEDOC lpOleDoc;
  173. int cRef; // interface specific ref count.
  174. } m_Unknown;
  175. struct CDocPersistFileImpl {
  176. IPersistFileVtbl FAR* lpVtbl;
  177. LPOLEDOC lpOleDoc;
  178. int cRef; // interface specific ref count.
  179. } m_PersistFile;
  180. struct CDocOleItemContainerImpl {
  181. IOleItemContainerVtbl FAR* lpVtbl;
  182. LPOLEDOC lpOleDoc;
  183. int cRef; // interface specific ref count.
  184. } m_OleItemContainer;
  185. struct CDocExternalConnectionImpl {
  186. IExternalConnectionVtbl FAR* lpVtbl;
  187. LPOLEDOC lpOleDoc;
  188. int cRef; // interface specific ref count.
  189. } m_ExternalConnection;
  190. struct CDocDataObjectImpl {
  191. IDataObjectVtbl FAR* lpVtbl;
  192. LPOLEDOC lpOleDoc;
  193. int cRef; // interface specific ref count.
  194. } m_DataObject;
  195. #ifdef USE_DRAGDROP
  196. struct CDocDropSourceImpl {
  197. IDropSourceVtbl FAR* lpVtbl;
  198. LPOLEDOC lpOleDoc;
  199. int cRef; // interface specific ref count.
  200. } m_DropSource;
  201. struct CDocDropTargetImpl {
  202. IDropTargetVtbl FAR* lpVtbl;
  203. LPOLEDOC lpOleDoc;
  204. int cRef; // interface specific ref count.
  205. } m_DropTarget;
  206. #endif // USE_DRAGDROP
  207. } OLEDOC;
  208. /* OleDoc methods (functions) */
  209. BOOL OleDoc_Init(LPOLEDOC lpOleDoc, BOOL fDataTransferDoc);
  210. BOOL OleDoc_InitNewFile(LPOLEDOC lpOleDoc);
  211. void OleDoc_ShowWindow(LPOLEDOC lpOleDoc);
  212. void OleDoc_HideWindow(LPOLEDOC lpOleDoc, BOOL fShutDown);
  213. HRESULT OleDoc_Lock(LPOLEDOC lpOleDoc, BOOL fLock, BOOL fLastUnlockReleases);
  214. ULONG OleDoc_AddRef(LPOLEDOC lpOleDoc);
  215. ULONG OleDoc_Release (LPOLEDOC lpOleDoc);
  216. HRESULT OleDoc_QueryInterface(
  217. LPOLEDOC lpOleDoc,
  218. REFIID riid,
  219. LPVOID FAR* lplpUnk
  220. );
  221. BOOL OleDoc_Close(LPOLEDOC lpOleDoc, DWORD dwSaveOption);
  222. void OleDoc_Destroy(LPOLEDOC lpOleDoc);
  223. void OleDoc_SetUpdateEditMenuFlag(LPOLEDOC lpOleDoc, BOOL fUpdate);
  224. BOOL OleDoc_GetUpdateEditMenuFlag(LPOLEDOC lpOleDoc);
  225. void OleDoc_GetExtent(LPOLEDOC lpOleDoc, LPSIZEL lpsizel);
  226. HGLOBAL OleDoc_GetObjectDescriptorData(
  227. LPOLEDOC lpOleDoc,
  228. LPLINERANGE lplrSel
  229. );
  230. LPMONIKER OleDoc_GetFullMoniker(LPOLEDOC lpOleDoc, DWORD dwAssign);
  231. void OleDoc_GetExtent(LPOLEDOC lpOleDoc, LPSIZEL lpsizel);
  232. void OleDoc_DocRenamedUpdate(LPOLEDOC lpOleDoc, LPMONIKER lpmkDoc);
  233. void OleDoc_CopyCommand(LPOLEDOC lpSrcOleDoc);
  234. void OleDoc_PasteCommand(LPOLEDOC lpOleDoc);
  235. void OleDoc_PasteSpecialCommand(LPOLEDOC lpOleDoc);
  236. LPOUTLINEDOC OleDoc_CreateDataTransferDoc(LPOLEDOC lpSrcOleDoc);
  237. BOOL OleDoc_PasteFromData(
  238. LPOLEDOC lpOleDoc,
  239. LPDATAOBJECT lpSrcDataObj,
  240. BOOL fLocalDataObj,
  241. BOOL fLink
  242. );
  243. BOOL OleDoc_PasteFormatFromData(
  244. LPOLEDOC lpOleDoc,
  245. CLIPFORMAT cfFormat,
  246. LPDATAOBJECT lpSrcDataObj,
  247. BOOL fLocalDataObj,
  248. BOOL fLink,
  249. BOOL fDisplayAsIcon,
  250. HGLOBAL hMetaPict,
  251. LPSIZEL lpSizelInSrc
  252. );
  253. BOOL OleDoc_QueryPasteFromData(
  254. LPOLEDOC lpOleDoc,
  255. LPDATAOBJECT lpSrcDataObj,
  256. BOOL fLink
  257. );
  258. #if defined( USE_DRAGDROP )
  259. BOOL OleDoc_QueryDrag( LPOLEDOC lpOleDoc, int y );
  260. BOOL OleDoc_QueryDrop (
  261. LPOLEDOC lpOleDoc,
  262. DWORD grfKeyState,
  263. POINTL pointl,
  264. BOOL fDragScroll,
  265. LPDWORD lpdwEffect
  266. );
  267. DWORD OleDoc_DoDragDrop (LPOLEDOC lpSrcOleDoc);
  268. BOOL OleDoc_DoDragScroll(LPOLEDOC lpOleDoc, POINTL pointl);
  269. #endif // USE_DRAGDROP
  270. /* OleDoc::IUnknown methods (functions) */
  271. STDMETHODIMP OleDoc_Unk_QueryInterface(
  272. LPUNKNOWN lpThis,
  273. REFIID riid,
  274. LPVOID FAR* lplpvObj
  275. );
  276. STDMETHODIMP_(ULONG) OleDoc_Unk_AddRef(LPUNKNOWN lpThis);
  277. STDMETHODIMP_(ULONG) OleDoc_Unk_Release (LPUNKNOWN lpThis);
  278. /* OleDoc::IPersistFile methods (functions) */
  279. STDMETHODIMP OleDoc_PFile_QueryInterface(
  280. LPPERSISTFILE lpThis,
  281. REFIID riid,
  282. LPVOID FAR* lplpvObj
  283. );
  284. STDMETHODIMP_(ULONG) OleDoc_PFile_AddRef(LPPERSISTFILE lpThis);
  285. STDMETHODIMP_(ULONG) OleDoc_PFile_Release (LPPERSISTFILE lpThis);
  286. STDMETHODIMP OleDoc_PFile_GetClassID (
  287. LPPERSISTFILE lpThis,
  288. CLSID FAR* lpclsid
  289. );
  290. STDMETHODIMP OleDoc_PFile_IsDirty(LPPERSISTFILE lpThis);
  291. STDMETHODIMP OleDoc_PFile_Load (
  292. LPPERSISTFILE lpThis,
  293. LPCOLESTR lpszFileName,
  294. DWORD grfMode
  295. );
  296. STDMETHODIMP OleDoc_PFile_Save (
  297. LPPERSISTFILE lpThis,
  298. LPCOLESTR lpszFileName,
  299. BOOL fRemember
  300. );
  301. STDMETHODIMP OleDoc_PFile_SaveCompleted (
  302. LPPERSISTFILE lpThis,
  303. LPCOLESTR lpszFileName
  304. );
  305. STDMETHODIMP OleDoc_PFile_GetCurFile (
  306. LPPERSISTFILE lpThis,
  307. LPOLESTR FAR* lplpszFileName
  308. );
  309. /* OleDoc::IOleItemContainer methods (functions) */
  310. STDMETHODIMP OleDoc_ItemCont_QueryInterface(
  311. LPOLEITEMCONTAINER lpThis,
  312. REFIID riid,
  313. LPVOID FAR* lplpvObj
  314. );
  315. STDMETHODIMP_(ULONG) OleDoc_ItemCont_AddRef(LPOLEITEMCONTAINER lpThis);
  316. STDMETHODIMP_(ULONG) OleDoc_ItemCont_Release(LPOLEITEMCONTAINER lpThis);
  317. STDMETHODIMP OleDoc_ItemCont_ParseDisplayName(
  318. LPOLEITEMCONTAINER lpThis,
  319. LPBC lpbc,
  320. LPOLESTR lpszDisplayName,
  321. ULONG FAR* lpchEaten,
  322. LPMONIKER FAR* lplpmkOut
  323. );
  324. STDMETHODIMP OleDoc_ItemCont_EnumObjects(
  325. LPOLEITEMCONTAINER lpThis,
  326. DWORD grfFlags,
  327. LPENUMUNKNOWN FAR* lplpenumUnknown
  328. );
  329. STDMETHODIMP OleDoc_ItemCont_LockContainer(
  330. LPOLEITEMCONTAINER lpThis,
  331. BOOL fLock
  332. );
  333. STDMETHODIMP OleDoc_ItemCont_GetObject(
  334. LPOLEITEMCONTAINER lpThis,
  335. LPOLESTR lpszItem,
  336. DWORD dwSpeedNeeded,
  337. LPBINDCTX lpbc,
  338. REFIID riid,
  339. LPVOID FAR* lplpvObject
  340. );
  341. STDMETHODIMP OleDoc_ItemCont_GetObjectStorage(
  342. LPOLEITEMCONTAINER lpThis,
  343. LPOLESTR lpszItem,
  344. LPBINDCTX lpbc,
  345. REFIID riid,
  346. LPVOID FAR* lplpvStorage
  347. );
  348. STDMETHODIMP OleDoc_ItemCont_IsRunning(
  349. LPOLEITEMCONTAINER lpThis,
  350. LPOLESTR lpszItem
  351. );
  352. /* OleDoc::IPersistFile methods (functions) */
  353. STDMETHODIMP OleDoc_ExtConn_QueryInterface(
  354. LPEXTERNALCONNECTION lpThis,
  355. REFIID riid,
  356. LPVOID FAR* lplpvObj
  357. );
  358. STDMETHODIMP_(ULONG) OleDoc_ExtConn_AddRef(LPEXTERNALCONNECTION lpThis);
  359. STDMETHODIMP_(ULONG) OleDoc_ExtConn_Release (LPEXTERNALCONNECTION lpThis);
  360. STDMETHODIMP_(DWORD) OleDoc_ExtConn_AddConnection(
  361. LPEXTERNALCONNECTION lpThis,
  362. DWORD extconn,
  363. DWORD reserved
  364. );
  365. STDMETHODIMP_(DWORD) OleDoc_ExtConn_ReleaseConnection(
  366. LPEXTERNALCONNECTION lpThis,
  367. DWORD extconn,
  368. DWORD reserved,
  369. BOOL fLastReleaseCloses
  370. );
  371. /* OleDoc::IDataObject methods (functions) */
  372. STDMETHODIMP OleDoc_DataObj_QueryInterface (
  373. LPDATAOBJECT lpThis,
  374. REFIID riid,
  375. LPVOID FAR* lplpvObj
  376. );
  377. STDMETHODIMP_(ULONG) OleDoc_DataObj_AddRef(LPDATAOBJECT lpThis);
  378. STDMETHODIMP_(ULONG) OleDoc_DataObj_Release (LPDATAOBJECT lpThis);
  379. STDMETHODIMP OleDoc_DataObj_GetData (
  380. LPDATAOBJECT lpThis,
  381. LPFORMATETC lpFormatetc,
  382. LPSTGMEDIUM lpMedium
  383. );
  384. STDMETHODIMP OleDoc_DataObj_GetDataHere (
  385. LPDATAOBJECT lpThis,
  386. LPFORMATETC lpFormatetc,
  387. LPSTGMEDIUM lpMedium
  388. );
  389. STDMETHODIMP OleDoc_DataObj_QueryGetData (
  390. LPDATAOBJECT lpThis,
  391. LPFORMATETC lpFormatetc
  392. );
  393. STDMETHODIMP OleDoc_DataObj_GetCanonicalFormatEtc(
  394. LPDATAOBJECT lpThis,
  395. LPFORMATETC lpformatetc,
  396. LPFORMATETC lpformatetcOut
  397. );
  398. STDMETHODIMP OleDoc_DataObj_SetData (
  399. LPDATAOBJECT lpThis,
  400. LPFORMATETC lpFormatetc,
  401. LPSTGMEDIUM lpMedium,
  402. BOOL fRelease
  403. );
  404. STDMETHODIMP OleDoc_DataObj_EnumFormatEtc(
  405. LPDATAOBJECT lpThis,
  406. DWORD dwDirection,
  407. LPENUMFORMATETC FAR* lplpenumFormatEtc
  408. );
  409. STDMETHODIMP OleDoc_DataObj_DAdvise(
  410. LPDATAOBJECT lpThis,
  411. FORMATETC FAR* lpFormatetc,
  412. DWORD advf,
  413. LPADVISESINK lpAdvSink,
  414. DWORD FAR* lpdwConnection
  415. );
  416. STDMETHODIMP OleDoc_DataObj_DUnadvise(LPDATAOBJECT lpThis,DWORD dwConnection);
  417. STDMETHODIMP OleDoc_DataObj_EnumDAdvise(
  418. LPDATAOBJECT lpThis,
  419. LPENUMSTATDATA FAR* lplpenumAdvise
  420. );
  421. #ifdef USE_DRAGDROP
  422. /* OleDoc::IDropSource methods (functions) */
  423. STDMETHODIMP OleDoc_DropSource_QueryInterface(
  424. LPDROPSOURCE lpThis,
  425. REFIID riid,
  426. LPVOID FAR* lplpvObj
  427. );
  428. STDMETHODIMP_(ULONG) OleDoc_DropSource_AddRef( LPDROPSOURCE lpThis );
  429. STDMETHODIMP_(ULONG) OleDoc_DropSource_Release ( LPDROPSOURCE lpThis);
  430. STDMETHODIMP OleDoc_DropSource_QueryContinueDrag (
  431. LPDROPSOURCE lpThis,
  432. BOOL fEscapePressed,
  433. DWORD grfKeyState
  434. );
  435. STDMETHODIMP OleDoc_DropSource_GiveFeedback (
  436. LPDROPSOURCE lpThis,
  437. DWORD dwEffect
  438. );
  439. /* OleDoc::IDropTarget methods (functions) */
  440. STDMETHODIMP OleDoc_DropTarget_QueryInterface(
  441. LPDROPTARGET lpThis,
  442. REFIID riid,
  443. LPVOID FAR* lplpvObj
  444. );
  445. STDMETHODIMP_(ULONG) OleDoc_DropTarget_AddRef(LPDROPTARGET lpThis);
  446. STDMETHODIMP_(ULONG) OleDoc_DropTarget_Release ( LPDROPTARGET lpThis);
  447. STDMETHODIMP OleDoc_DropTarget_DragEnter (
  448. LPDROPTARGET lpThis,
  449. LPDATAOBJECT lpDataObj,
  450. DWORD grfKeyState,
  451. POINTL pointl,
  452. LPDWORD lpdwEffect
  453. );
  454. STDMETHODIMP OleDoc_DropTarget_DragOver (
  455. LPDROPTARGET lpThis,
  456. DWORD grfKeyState,
  457. POINTL pointl,
  458. LPDWORD lpdwEffect
  459. );
  460. STDMETHODIMP OleDoc_DropTarget_DragLeave ( LPDROPTARGET lpThis);
  461. STDMETHODIMP OleDoc_DropTarget_Drop (
  462. LPDROPTARGET lpThis,
  463. LPDATAOBJECT lpDataObj,
  464. DWORD grfKeyState,
  465. POINTL pointl,
  466. LPDWORD lpdwEffect
  467. );
  468. #endif // USE_DRAGDROP
  469. /*************************************************************************
  470. ** class APPCLASSFACTORY
  471. ** APPCLASSFACTORY implements the IClassFactory interface. it
  472. ** instantiates document instances of the correct type depending on
  473. ** how the application is compiled (either ServerDoc or ContainerDoc
  474. ** instances). by implementing this
  475. ** interface in a seperate interface from the App object itself, it
  476. ** is easier to manage when the IClassFactory should be
  477. ** registered/revoked. when the OleApp object is first initialized
  478. ** in OleApp_InitInstance an instance of APPCLASSFACTORY is created
  479. ** and registered (CoRegisterClassObject called). when the App
  480. ** object gets destroyed (in OleApp_Destroy) this APPCLASSFACTORY is
  481. ** revoked (CoRevokeClassObject called) and released. the simple
  482. ** fact that the IClassFactory is registered does not on its own keep
  483. ** the application alive.
  484. *************************************************************************/
  485. typedef struct tagAPPCLASSFACTORY {
  486. IClassFactoryVtbl FAR* m_lpVtbl;
  487. UINT m_cRef;
  488. #if defined( _DEBUG )
  489. LONG m_cSvrLock; // total count of LockServer locks
  490. // (for debugging purposes only)
  491. #endif
  492. } APPCLASSFACTORY, FAR* LPAPPCLASSFACTORY;
  493. /* PUBLIC FUNCTIONS */
  494. LPCLASSFACTORY WINAPI AppClassFactory_Create(void);
  495. /* interface IClassFactory implementation */
  496. STDMETHODIMP AppClassFactory_QueryInterface(
  497. LPCLASSFACTORY lpThis, REFIID riid, LPVOID FAR* ppvObj);
  498. STDMETHODIMP_(ULONG) AppClassFactory_AddRef(LPCLASSFACTORY lpThis);
  499. STDMETHODIMP_(ULONG) AppClassFactory_Release(LPCLASSFACTORY lpThis);
  500. STDMETHODIMP AppClassFactory_CreateInstance (
  501. LPCLASSFACTORY lpThis,
  502. LPUNKNOWN lpUnkOuter,
  503. REFIID riid,
  504. LPVOID FAR* lplpvObj
  505. );
  506. STDMETHODIMP AppClassFactory_LockServer (
  507. LPCLASSFACTORY lpThis,
  508. BOOL fLock
  509. );
  510. /*************************************************************************
  511. ** class OLEAPP : OUTLINEAPP
  512. ** OLEAPP is an extention to the base OUTLINEAPP object (structure)
  513. ** that adds common OLE 2.0 functionality used by both the server
  514. ** and container versions. This is an abstract class. You do not
  515. ** instantiate an instance of OLEAPP directly but instead
  516. ** instantiate one of its concrete subclasses: SERVERAPP or
  517. ** CONTAINERAPP. There is one instance of an document application
  518. ** object created per running application instance. This
  519. ** object holds many fields that could otherwise be organized as
  520. ** global variables. The OLEAPP class inherits all fields
  521. ** from the OUTLINEAPP class. This inheritance is achieved by including a
  522. ** member variable of type OUTLINEAPP as the first field in the OLEAPP
  523. ** structure. Thus a pointer to a OLEAPP object can be cast to be
  524. ** a pointer to a OUTLINEAPP object.
  525. *************************************************************************/
  526. typedef struct tagOLEAPP {
  527. OUTLINEAPP m_OutlineApp; // inherits all fields of OutlineApp
  528. ULONG m_cRef; // total ref count for app
  529. ULONG m_cDoc; // total count of open documents
  530. BOOL m_fUserCtrl; // does user control life-time of app?
  531. DWORD m_dwRegClassFac; // value returned by CoRegisterClassObject
  532. LPCLASSFACTORY m_lpClassFactory;// ptr to allocated ClassFactory instance
  533. #if defined( USE_MSGFILTER )
  534. LPMESSAGEFILTER m_lpMsgFilter; // ptr to allocated MsgFilter instance
  535. MSGPENDINGPROC m_lpfnMsgPending;// ptr to msg pending callback function
  536. #endif // USE_MSGFILTER
  537. BOOL m_fOleInitialized; // was OleInitialize called
  538. UINT m_cModalDlgActive; // count of modal dialogs up; 0 = no dlg.
  539. UINT m_cfEmbedSource; // OLE 2.0 clipboard format
  540. UINT m_cfEmbeddedObject; // OLE 2.0 clipboard format
  541. UINT m_cfLinkSource; // OLE 2.0 clipboard format
  542. UINT m_cfObjectDescriptor; // OLE 2.0 clipboard format
  543. UINT m_cfLinkSrcDescriptor; // OLE 2.0 clipboard format
  544. UINT m_cfFileName; // std Windows clipboard format
  545. FORMATETC m_arrDocGetFmts[MAXNOFMTS]; // fmts offered by copy & GetData
  546. UINT m_nDocGetFmts; // no of fmtetc's for GetData
  547. OLEUIPASTEENTRY m_arrPasteEntries[MAXNOFMTS]; // input for PasteSpl.
  548. int m_nPasteEntries; // input for PasteSpl.
  549. UINT m_arrLinkTypes[MAXNOLINKTYPES]; // input for PasteSpl.
  550. int m_nLinkTypes; // input for PasteSpl.
  551. #if defined( USE_DRAGDROP )
  552. int m_nDragDelay; // time delay (in msec) before drag should start
  553. int m_nDragMinDist; // min. distance (radius) before drag should start
  554. int m_nScrollDelay; // time delay (in msec) before scroll should start
  555. int m_nScrollInset; // Border inset distance to start drag scroll
  556. int m_nScrollInterval; // scroll interval time (in msec)
  557. #if defined( IF_SPECIAL_DD_CURSORS_NEEDED )
  558. // This would be used if the app wanted to have custom drag/drop cursors
  559. HCURSOR m_hcursorDragNone;
  560. HCURSOR m_hcursorDragCopy;
  561. HCURSOR m_hcursorDragLink;
  562. #endif // IF_SPECIAL_DD_CURSORS_NEEDED
  563. #endif // USE_DRAGDROP
  564. #if defined( OLE_CNTR )
  565. HPALETTE m_hStdPal; // standard color palette for OLE
  566. // it is a good idea for containers
  567. // to use this standard palette
  568. // even if they do not use colors
  569. // themselves. this will allow
  570. // embedded object to get a good
  571. // distribution of colors when they
  572. // are being drawn by the container.
  573. //
  574. #endif
  575. struct CAppUnknownImpl {
  576. IUnknownVtbl FAR* lpVtbl;
  577. LPOLEAPP lpOleApp;
  578. int cRef; // interface specific ref count.
  579. } m_Unknown;
  580. } OLEAPP;
  581. /* ServerApp methods (functions) */
  582. BOOL OleApp_InitInstance(LPOLEAPP lpOleApp, HINSTANCE hInst, int nCmdShow);
  583. void OleApp_TerminateApplication(LPOLEAPP lpOleApp);
  584. BOOL OleApp_ParseCmdLine(LPOLEAPP lpOleApp, LPSTR lpszCmdLine, int nCmdShow);
  585. void OleApp_Destroy(LPOLEAPP lpOleApp);
  586. BOOL OleApp_CloseAllDocsAndExitCommand(
  587. LPOLEAPP lpOleApp,
  588. BOOL fForceEndSession
  589. );
  590. void OleApp_ShowWindow(LPOLEAPP lpOleApp, BOOL fGiveUserCtrl);
  591. void OleApp_HideWindow(LPOLEAPP lpOleApp);
  592. void OleApp_HideIfNoReasonToStayVisible(LPOLEAPP lpOleApp);
  593. void OleApp_DocLockApp(LPOLEAPP lpOleApp);
  594. void OleApp_DocUnlockApp(LPOLEAPP lpOleApp, LPOUTLINEDOC lpOutlineDoc);
  595. HRESULT OleApp_Lock(LPOLEAPP lpOleApp, BOOL fLock, BOOL fLastUnlockReleases);
  596. ULONG OleApp_AddRef(LPOLEAPP lpOleApp);
  597. ULONG OleApp_Release (LPOLEAPP lpOleApp);
  598. HRESULT OleApp_QueryInterface (
  599. LPOLEAPP lpOleApp,
  600. REFIID riid,
  601. LPVOID FAR* lplpUnk
  602. );
  603. void OleApp_RejectInComingCalls(LPOLEAPP lpOleApp, BOOL fReject);
  604. void OleApp_DisableBusyDialogs(
  605. LPOLEAPP lpOleApp,
  606. BOOL FAR* lpfPrevBusyEnable,
  607. BOOL FAR* lpfPrevNREnable
  608. );
  609. void OleApp_EnableBusyDialogs(
  610. LPOLEAPP lpOleApp,
  611. BOOL fPrevBusyEnable,
  612. BOOL fPrevNREnable
  613. );
  614. void OleApp_PreModalDialog(LPOLEAPP lpOleApp, LPOLEDOC lpActiveOleDoc);
  615. void OleApp_PostModalDialog(LPOLEAPP lpOleApp, LPOLEDOC lpActiveOleDoc);
  616. BOOL OleApp_InitVtbls (LPOLEAPP lpOleApp);
  617. void OleApp_InitMenu(
  618. LPOLEAPP lpOleApp,
  619. LPOLEDOC lpOleDoc,
  620. HMENU hMenu
  621. );
  622. void OleApp_UpdateEditMenu(
  623. LPOLEAPP lpOleApp,
  624. LPOUTLINEDOC lpOutlineDoc,
  625. HMENU hMenuEdit
  626. );
  627. BOOL OleApp_RegisterClassFactory(LPOLEAPP lpOleApp);
  628. void OleApp_RevokeClassFactory(LPOLEAPP lpOleApp);
  629. #if defined( USE_MSGFILTER )
  630. BOOL OleApp_RegisterMessageFilter(LPOLEAPP lpOleApp);
  631. void OleApp_RevokeMessageFilter(LPOLEAPP lpOleApp);
  632. BOOL FAR PASCAL EXPORT MessagePendingProc(MSG FAR *lpMsg);
  633. #endif // USE_MSGFILTER
  634. void OleApp_FlushClipboard(LPOLEAPP lpOleApp);
  635. void OleApp_NewCommand(LPOLEAPP lpOleApp);
  636. void OleApp_OpenCommand(LPOLEAPP lpOleApp);
  637. #if defined( OLE_CNTR )
  638. LRESULT OleApp_QueryNewPalette(LPOLEAPP lpOleApp);
  639. #endif // OLE_CNTR
  640. LRESULT wSelectPalette(HWND hWnd, HPALETTE hPal, BOOL fBackground);
  641. /* OleApp::IUnknown methods (functions) */
  642. STDMETHODIMP OleApp_Unk_QueryInterface(
  643. LPUNKNOWN lpThis,
  644. REFIID riid,
  645. LPVOID FAR* lplpvObj
  646. );
  647. STDMETHODIMP_(ULONG) OleApp_Unk_AddRef(LPUNKNOWN lpThis);
  648. STDMETHODIMP_(ULONG) OleApp_Unk_Release (LPUNKNOWN lpThis);
  649. /* Function prototypes in debug.c */
  650. void InstallMessageFilterCommand(void);
  651. void RejectIncomingCommand(void);
  652. #if defined( OLE_SERVER )
  653. #include "svroutl.h"
  654. #endif
  655. #if defined( OLE_CNTR )
  656. #include "cntroutl.h"
  657. #endif
  658. #endif // _OLEOUTL_H_
  659.