SITE.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * SITE.H
  3.  * View Site for Document Objects.
  4.  *
  5.  * Copyright (c)1995-1997 Microsoft Corporation, All Rights Reserved
  6.  */
  7. #ifndef _SITE_H_
  8. #define _SITE_H_
  9. class CImpIOleClientSite : public IOleClientSite
  10.     {
  11.     protected:
  12.         ULONG               m_cRef;
  13.         class CSite        *m_pSite;
  14.         LPUNKNOWN           m_pUnkOuter;
  15.     public:
  16.         CImpIOleClientSite(class CSite *, IUnknown *);
  17.         ~CImpIOleClientSite(void);
  18.         STDMETHODIMP QueryInterface(REFIID, void **);
  19.         STDMETHODIMP_(ULONG) AddRef(void);
  20.         STDMETHODIMP_(ULONG) Release(void);
  21.         STDMETHODIMP SaveObject(void);
  22.         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
  23.         STDMETHODIMP GetContainer(LPOLECONTAINER *);
  24.         STDMETHODIMP ShowObject(void);
  25.         STDMETHODIMP OnShowWindow(BOOL);
  26.         STDMETHODIMP RequestNewObjectLayout(void);
  27.     };
  28. typedef CImpIOleClientSite *PCImpIOleClientSite;
  29. class CImpIAdviseSink : public IAdviseSink
  30.     {
  31.     protected:
  32.         ULONG               m_cRef;
  33.         class CSite        *m_pSite;
  34.         LPUNKNOWN           m_pUnkOuter;
  35.     public:
  36.         CImpIAdviseSink(class CSite *, IUnknown *);
  37.         ~CImpIAdviseSink(void);
  38.         STDMETHODIMP QueryInterface(REFIID, void **);
  39.         STDMETHODIMP_(ULONG) AddRef(void);
  40.         STDMETHODIMP_(ULONG) Release(void);
  41.         STDMETHODIMP_(void)  OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  42.         STDMETHODIMP_(void)  OnViewChange(DWORD, LONG);
  43.         STDMETHODIMP_(void)  OnRename(LPMONIKER);
  44.         STDMETHODIMP_(void)  OnSave(void);
  45.         STDMETHODIMP_(void)  OnClose(void);
  46.     };
  47. typedef CImpIAdviseSink *PCImpIAdviseSink;
  48. class CImpIOleInPlaceSite : public IOleInPlaceSite
  49.     {
  50.     protected:
  51.         ULONG               m_cRef;
  52.         class CSite        *m_pSite;
  53.         LPUNKNOWN           m_pUnkOuter;
  54.     public:
  55.         CImpIOleInPlaceSite(class CSite *, IUnknown *);
  56.         ~CImpIOleInPlaceSite(void);
  57.         STDMETHODIMP QueryInterface(REFIID, void **);
  58.         STDMETHODIMP_(ULONG) AddRef(void);
  59.         STDMETHODIMP_(ULONG) Release(void);
  60.         STDMETHODIMP GetWindow(HWND *);
  61.         STDMETHODIMP ContextSensitiveHelp(BOOL);
  62.         STDMETHODIMP CanInPlaceActivate(void);
  63.         STDMETHODIMP OnInPlaceActivate(void);
  64.         STDMETHODIMP OnUIActivate(void);
  65.         STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME *
  66.                         , LPOLEINPLACEUIWINDOW *, LPRECT, LPRECT
  67.                         , LPOLEINPLACEFRAMEINFO);
  68.         STDMETHODIMP Scroll(SIZE);
  69.         STDMETHODIMP OnUIDeactivate(BOOL);
  70.         STDMETHODIMP OnInPlaceDeactivate(void);
  71.         STDMETHODIMP DiscardUndoState(void);
  72.         STDMETHODIMP DeactivateAndUndo(void);
  73.         STDMETHODIMP OnPosRectChange(LPCRECT);
  74.     };
  75. typedef CImpIOleInPlaceSite *PCImpIOleInPlaceSite;
  76. class CImpIOleDocumentSite : public IOleDocumentSite
  77.     {
  78.     protected:
  79.         ULONG               m_cRef;
  80.         class CSite        *m_pSite;
  81.         LPUNKNOWN           m_pUnkOuter;
  82.     public:
  83.         CImpIOleDocumentSite(class CSite *, IUnknown *);
  84.         ~CImpIOleDocumentSite(void);
  85.         STDMETHODIMP QueryInterface(REFIID, void **);
  86.         STDMETHODIMP_(ULONG) AddRef(void);
  87.         STDMETHODIMP_(ULONG) Release(void);
  88.         STDMETHODIMP ActivateMe(IOleDocumentView *);
  89.     };
  90. typedef CImpIOleDocumentSite *PCImpIOleDocumentSite;
  91. /*
  92.  * The CSite class, a COM object with the interfaces IOleClientSite,
  93.  * IAdviseSink, IOleInPlaceSite, and IOleDocumentSite.
  94.  */
  95. class CSite : public IUnknown
  96.     {
  97.     friend CImpIOleClientSite;
  98.     friend CImpIAdviseSink;
  99.     friend CImpIOleInPlaceSite;
  100.     friend CImpIOleDocumentSite;
  101.     private:
  102.         ULONG           m_cRef;
  103.         DWORD           m_dwID;
  104.         HWND            m_hWnd; //Client area window of parent
  105.         class CFrame   *m_pFR;
  106.         BOOL            m_fInitialized; //Something here?
  107.         LPSTORAGE       m_pIStorage;    //Storage for object
  108. LPSTREAM m_pIStream; //Info stream for object
  109.         //Object interfaces
  110.         IUnknown          *m_pObj;
  111.         IOleObject        *m_pIOleObject;
  112.         IOleInPlaceObject *m_pIOleIPObject;
  113.         IOleDocumentView  *m_pIOleDocView;
  114.         BOOL               m_fDocObj;   //Document object here?
  115.         //Our interfaces
  116.         PCImpIOleClientSite   m_pImpIOleClientSite;
  117.         PCImpIAdviseSink      m_pImpIAdviseSink;
  118.         PCImpIOleInPlaceSite  m_pImpIOleIPSite;
  119.         PCImpIOleDocumentSite m_pImpIOleDocumentSite;
  120.     protected:
  121.         BOOL    ObjectInitialize(LPUNKNOWN);
  122.     public:
  123.         CSite(DWORD, HWND, CFrame *);
  124.         ~CSite(void);
  125.         //Gotta have an IUnknown for delegation
  126.         STDMETHODIMP QueryInterface(REFIID, void **);
  127.         STDMETHODIMP_(ULONG) AddRef(void);
  128.         STDMETHODIMP_(ULONG) Release(void);
  129.         BOOL        Create(LPTSTR, IStorage *);
  130.         BOOL        CreateStorage(IStorage *);
  131.         void        Close(BOOL);
  132.         void        Update(void);
  133.         void        Destroy(IStorage *);
  134.         void        Activate(LONG);
  135.         void        UpdateObjectRects(void);
  136.     };
  137. typedef CSite *PCSite;
  138. #endif //_SITE_H_