TENANT.H
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:16k
源码类别:
Windows编程
开发平台:
Visual C++
- /*
- * TENANT.H
- * Patron Chapter 24
- *
- * Definitions and function prototypes for the CTenant class
- *
- * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
- *
- * Kraig Brockschmidt, Microsoft
- * Internet : kraigb@microsoft.com
- * Compuserve: >INTERNET:kraigb@microsoft.com
- */
- #ifndef _TENANT_H_
- #define _TENANT_H_
- class CImpIOleClientSite : public IOleClientSite
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- LPUNKNOWN m_pUnkOuter;
- public:
- CImpIOleClientSite(class CTenant *, LPUNKNOWN);
- ~CImpIOleClientSite(void);
- STDMETHODIMP QueryInterface(REFIID, PPVOID);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP SaveObject(void);
- STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
- STDMETHODIMP GetContainer(LPOLECONTAINER *);
- STDMETHODIMP ShowObject(void);
- STDMETHODIMP OnShowWindow(BOOL);
- STDMETHODIMP RequestNewObjectLayout(void);
- };
- typedef CImpIOleClientSite *PCImpIOleClientSite;
- class CImpIAdviseSink : public IAdviseSink
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- LPUNKNOWN m_pUnkOuter;
- public:
- CImpIAdviseSink(class CTenant *, LPUNKNOWN);
- ~CImpIAdviseSink(void);
- STDMETHODIMP QueryInterface(REFIID, PPVOID);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM);
- STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
- STDMETHODIMP_(void) OnRename(LPMONIKER);
- STDMETHODIMP_(void) OnSave(void);
- STDMETHODIMP_(void) OnClose(void);
- };
- typedef CImpIAdviseSink *PCImpIAdviseSink;
- class CImpIOleInPlaceSite : public IOleInPlaceSite
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- LPUNKNOWN m_pUnkOuter;
- public:
- CImpIOleInPlaceSite(class CTenant *, LPUNKNOWN);
- ~CImpIOleInPlaceSite(void);
- STDMETHODIMP QueryInterface(REFIID, PPVOID);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP GetWindow(HWND *);
- STDMETHODIMP ContextSensitiveHelp(BOOL);
- STDMETHODIMP CanInPlaceActivate(void);
- STDMETHODIMP OnInPlaceActivate(void);
- STDMETHODIMP OnUIActivate(void);
- STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME *
- , LPOLEINPLACEUIWINDOW *, LPRECT, LPRECT
- , LPOLEINPLACEFRAMEINFO);
- STDMETHODIMP Scroll(SIZE);
- STDMETHODIMP OnUIDeactivate(BOOL);
- STDMETHODIMP OnInPlaceDeactivate(void);
- STDMETHODIMP DiscardUndoState(void);
- STDMETHODIMP DeactivateAndUndo(void);
- STDMETHODIMP OnPosRectChange(LPCRECT);
- };
- typedef CImpIOleInPlaceSite *PCImpIOleInPlaceSite;
- //CHAPTER24MOD
- class CImpIOleControlSite : public IOleControlSite
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- LPUNKNOWN m_pUnkOuter;
- public:
- CImpIOleControlSite(class CTenant *, LPUNKNOWN);
- ~CImpIOleControlSite(void);
- STDMETHODIMP QueryInterface(REFIID, LPVOID *);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP OnControlInfoChanged(void);
- STDMETHODIMP LockInPlaceActive(BOOL);
- STDMETHODIMP GetExtendedControl(LPDISPATCH *);
- STDMETHODIMP TransformCoords(POINTL *, POINTF *, DWORD);
- STDMETHODIMP TranslateAccelerator(LPMSG, DWORD);
- STDMETHODIMP OnFocus(BOOL);
- STDMETHODIMP ShowPropertyFrame(void);
- };
- typedef class CImpIOleControlSite *PCImpIOleControlSite;
- //This IDispatch implements Ambient properties
- class CImpIDispatch : public IDispatch
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- LPUNKNOWN m_pUnkOuter;
- public:
- CImpIDispatch(class CTenant *, LPUNKNOWN);
- ~CImpIDispatch(void);
- STDMETHODIMP QueryInterface(REFIID, LPVOID *);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP GetTypeInfoCount(UINT *);
- STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
- STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT
- , LCID, DISPID *);
- STDMETHODIMP Invoke(DISPID, REFIID, LCID, USHORT
- , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
- };
- typedef class CImpIDispatch *PCImpIDispatch;
- //Events IDispatch created once for each outgoing event set.
- class CDispatchEvents : public IDispatch
- {
- protected:
- ULONG m_cRef;
- class CTenant *m_pTen;
- public:
- CDispatchEvents(class CTenant *);
- ~CDispatchEvents(void);
- STDMETHODIMP QueryInterface(REFIID, LPVOID *);
- STDMETHODIMP_(ULONG) AddRef(void);
- STDMETHODIMP_(ULONG) Release(void);
- STDMETHODIMP GetTypeInfoCount(UINT *);
- STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
- STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT
- , LCID, DISPID *);
- STDMETHODIMP Invoke(DISPID, REFIID, LCID, USHORT
- , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
- };
- typedef class CDispatchEvents *PCDispatchEvents;
- //End CHAPTER24MOD
- /*
- * Tenant class describing an individual piece of data in a page.
- * It knows where it sits, what object is inside of it, and what
- * its idenitifer is such that it can find it's storage within a
- * page.
- */
- //Patron Objects clipboard format
- typedef struct tagPATRONOBJECT
- {
- POINTL ptl; //Location of object
- POINTL ptlPick; //Pick point from drag-drop operation
- SIZEL szl; //Extents of object (absolute)
- FORMATETC fe; //Actual object format
- } PATRONOBJECT, *PPATRONOBJECT;
- //Values for hit-testing, drawing, and resize-tracking tenants
- #define CXYHANDLE 5
- //Tenant types (not persistent, but determined at load time)
- typedef enum
- {
- TENANTTYPE_NULL=0,
- TENANTTYPE_STATIC,
- TENANTTYPE_EMBEDDEDOBJECT,
- TENANTTYPE_EMBEDDEDFILE,
- TENANTTYPE_EMBEDDEDOBJECTFROMDATA,
- TENANTTYPE_LINKEDOBJECT,
- TENANTTYPE_LINKEDFILE,
- TENANTTYPE_LINKEDOBJECTFROMDATA
- } TENANTTYPE, *PTENANTTYPE;
- //State flags
- //CHAPTER24MOD
- //Switched #defines to an enum
- enum
- {
- TENANTSTATE_DEFAULT =0x00000000,
- TENANTSTATE_SELECTED=0x00000001,
- TENANTSTATE_OPEN =0x00000002,
- TENANTSTATE_SHOWTYPE=0x00000004,
- //New ones for controls.
- TENANTSTATE_CONTROL =0x00000100,
- TENANTSTATE_EVENTS =0x00000200,
- TENANTSTATE_BUTTON =0x00000400,
- TENANTSTATE_LABEL =0x00000800,
- TENANTSTATE_DEFBUTTON =0x00001000,
- TENANTSTATE_CANCELBUTTON=0x00002000
- };
- //To mask off non-control flags
- #define STATEMASK_CONTROLS 0xFFFFFF00
- //End CHAPTER24MOD
- /*
- * Persistent information we need to save for each tenant, which is
- * done in the tenant list instead of with each tenant. Since this
- * is a small structure it's best not to blow another stream for it
- * (overhead).
- */
- typedef struct tagTENANTINFO
- {
- DWORD dwID;
- RECTL rcl;
- FORMATETC fe; //Excludes ptd
- short fSetExtent; //Call IOleObject::SetExtent on Run
- } TENANTINFO, *PTENANTINFO;
- //CHAPTER24MOD
- /*
- * Event handling constructs: EVENTACTION is the type of
- * action to execute on an event. EVENTMAP is an element of
- * an array to hold event mappings.
- */
- typedef enum
- {
- ACTION_NONE=-1,
- ACTION_BEEPDEFAULT=MB_OK,
- ACTION_BEEPASTERISK=MB_ICONASTERISK,
- ACTION_BEEPEXCLAMATION=MB_ICONEXCLAMATION,
- ACTION_BEEPHAND=MB_ICONHAND,
- ACTION_BEEPQUESTION=MB_ICONQUESTION,
- ACTION_TAILING=-2
- } EVENTACTION;
- typedef struct tagEVENTMAP
- {
- DISPID id; //Event ID
- EVENTACTION iAction; //Action to take
- BSTR bstrName; //Event name (function only)
- } EVENTMAP, *PEVENTMAP;
- class CEventMap
- {
- public:
- UINT m_cEvents;
- LPTYPEINFO m_pITypeInfo;
- PEVENTMAP m_pEventMap;
- public:
- CEventMap(LPTYPEINFO);
- ~CEventMap(void);
- BOOL Init(void);
- BOOL Set(DISPID, EVENTACTION);
- EVENTACTION Get(DISPID);
- void Serialize(LPSTREAM);
- void Deserialize(LPSTREAM);
- };
- typedef CEventMap *PCEventMap;
- //Events stream in the object storage
- #define SZEVENTSSTREAM OLETEXT("