home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / activexcontrol / basectl / todosvr / cdocobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-05  |  6.5 KB  |  161 lines

  1. //=--------------------------------------------------------------------------=
  2. // CDocObj.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 - 1997 Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // class declaration for the document object server class.
  13. //
  14. #ifndef __CDOCOBJ_H_
  15. #define __CDOCOBJ_H_
  16.  
  17. #ifndef __MKTYPLIB__
  18.  
  19. #include <IPServer.H>
  20. #include <internet.h>
  21.  
  22. //=--------------------------------------------------------------------------=
  23. // DOCOBJECTINFO
  24. //=--------------------------------------------------------------------------=
  25. // for each DocObject you wish to expose to the programmer/user, you need to
  26. // declare and define one of the following structures.  the first part should
  27. // follow the rules of the CONTROLOBJECTINFO structure.  
  28. // once this structre is declared/defined, an entry should be put in the
  29. // global g_ObjectInfo table.
  30. //
  31. typedef struct {
  32.     CONTROLOBJECTINFO ControlInfo;            // control, automation and creation information
  33.     DWORD             dwMiscDocObj;        // value of DocObject subkey
  34.     BOOL              bPrint;            // IPrint interface supported
  35.     UINT              nIDszExt;            // resource ID of default file extension
  36.     UINT              nIDszFileDescription; // resource ID of file description 
  37. } DOCOBJECTINFO;
  38.  
  39. #ifndef INITOBJECTS
  40.  
  41. #define DEFINE_DOCOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, dwmisc, bprint, nidext, niddesc) \
  42. extern DOCOBJECTINFO name##DocObj \
  43.  
  44. #else
  45. #define DEFINE_DOCOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, dwmisc, bprint, nidext, niddesc) \
  46. DOCOBJECTINFO name##DocObj = { { { {clsid, progid, fn}, ver, riid, pszh, NULL, 0}, piide, dwcf, dwap, TRUE, FALSE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL }, dwmisc, bprint, nidext, niddesc }\
  47.  
  48.  
  49. #endif // !INITOBJECTS
  50.  
  51. #define MISCFLAGSOFDOCOBJECT(index)         ((DOCOBJECTINFO *)(g_ObjectInfo[index].pInfo))->dwMiscDocObj
  52. #define PRINTOFDOCOBJECT(index)             ((DOCOBJECTINFO *)(g_ObjectInfo[index].pInfo))->bPrint
  53. #define DEFAULTEXTIDOFDOCOBJECT(index)      ((DOCOBJECTINFO *)(g_ObjectInfo[index].pInfo))->nIDszExt
  54. #define FILEDESCRIPTIONIDOFDOCOBJECT(index) ((DOCOBJECTINFO *)(g_ObjectInfo[index].pInfo))->nIDszFileDescription
  55.  
  56.  
  57. // this is the macros you should use to fill in the table.  Note that the name
  58. // must be exactly the same as that used in the global structure you created
  59. // for this object.
  60. //
  61. // if we were adding docobj support right into the framework, we would
  62. // put this definition in localobj.h, and instead of using the OI_CONTROL
  63. // type, we would define a new type (eg OI_DOCOBJ). 
  64. //
  65. #define DOCOBJECT(name)    { OI_CONTROL,      (void *)&(name##DocObj) }
  66.  
  67.  
  68. //=--------------------------------------------------------------------------=
  69. // CDocumentObject
  70. //=--------------------------------------------------------------------------=
  71. //
  72. // if you don't want internet-aware support, change BASECLASS to COleControl
  73. //
  74. #define BASECLASS   CInternetControl
  75.  
  76. class CDocumentObject : public BASECLASS, public IOleDocument, public IOleDocumentView
  77. {
  78. public:
  79.     // constructor and destructor
  80.     //
  81.     CDocumentObject(IUnknown* pUnkOuter, int iPrimaryDispatch, void* pMainInterface);
  82.     virtual ~CDocumentObject();
  83.  
  84.     // IUnknown methods
  85.     //
  86.     DECLARE_STANDARD_UNKNOWN();
  87.  
  88.     // IOleObject method overrides for DocObject support
  89.     STDMETHOD(SetClientSite)(IOleClientSite* pClientSite);
  90.     STDMETHOD(DoVerb)(LONG iVerb, LPMSG lpmsg, IOleClientSite  *pActiveSite, LONG lindex,
  91.                                      HWND hwndParent, LPCRECT lprcPosRect);
  92.     STDMETHOD(SetExtent)(DWORD dwDrawAspect, SIZEL *psizel);
  93.     STDMETHOD(Unadvise)(DWORD dwConnection);
  94.  
  95.     // IOleDocument -- required DocObject server interface
  96.     //
  97.     STDMETHOD(CreateView)(IOleInPlaceSite* pIPSite, IStream* pstm,
  98.                           DWORD dwReserved, IOleDocumentView** ppView);
  99.     STDMETHOD(GetDocMiscStatus)(DWORD* pdwStatus);
  100.     STDMETHOD(EnumViews)(IEnumOleDocumentViews** ppEnum, IOleDocumentView** ppView);
  101.     
  102.     // IOleDocumentView -- required DocObject server interface
  103.     //
  104.     STDMETHOD(SetInPlaceSite)(IOleInPlaceSite* pIPSite);
  105.     STDMETHOD(GetInPlaceSite)(IOleInPlaceSite** ppIPSite);
  106.     STDMETHOD(GetDocument)(IUnknown** ppunk);
  107.     STDMETHOD(SetRect)(LPRECT prcView);
  108.     STDMETHOD(GetRect)(LPRECT prcView);
  109.     STDMETHOD(SetRectComplex)(LPRECT prcView, LPRECT prcHScroll,
  110.                               LPRECT prcVScroll, LPRECT prcSizeBox);
  111.     STDMETHOD(Show)(BOOL fShow);
  112.     STDMETHOD(UIActivate)(BOOL fUIActivate);
  113.     STDMETHOD(Open)(void);
  114.     STDMETHOD(CloseView)(ULONG ulReserved);
  115.     STDMETHOD(SaveViewState)(LPSTREAM pstm);
  116.     STDMETHOD(ApplyViewState)(LPSTREAM pstm);
  117.     STDMETHOD(Clone)(IOleInPlaceSite* pIPSiteNew, IOleDocumentView** ppViewNew);
  118.  
  119.     // Override base class implementation...
  120.     virtual HRESULT InternalQueryInterface(REFIID, void**);
  121.  
  122. protected:
  123.     BOOL              m_fDocObj;
  124.     IOleDocumentSite* m_pDocSite;
  125.     IOleInPlaceSite*  m_pViewSite;
  126.  
  127.     // Functions to override to save/restore view state
  128.     virtual HRESULT OnSaveViewState(IStream* pstm);
  129.     virtual HRESULT OnApplyViewState(IStream* pstm);
  130.  
  131.     // Helper function for DocObject activation
  132.     HRESULT ActivateAsDocObject(LONG lVerb);
  133.  
  134. };
  135.  
  136.  
  137. //=--------------------------------------------------------------------------=
  138. // helper functions
  139. //=--------------------------------------------------------------------------=
  140. //
  141. BOOL RegisterDocObject(LPCSTR pszLibName, LPCSTR pszObjectName,
  142.                        REFCLSID riidObject, DWORD dwMiscDocObj,
  143.                        BOOL bPrint, LPCSTR szExt, LPCSTR szDescription);
  144.  
  145. //=--------------------------------------------------------------------------=
  146. // Debugging macros
  147. //=--------------------------------------------------------------------------=
  148. // handy-dandy TRACE macro is useful for figuring out how docobj containers
  149. // are calling our interface methods 
  150. //
  151. #ifdef DEBUG
  152.     #define TRACE(szMsg)    OutputDebugString(szMsg)
  153. #else
  154.     #define TRACE(szMsg)
  155. #endif
  156.  
  157. #endif __MKTYPLIB__
  158.  
  159. #endif __CDOCOBJ_H_
  160.  
  161.