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

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * POLYLINE.H
  3.  * Polyline Component Chapter 24
  4.  *
  5.  * Definitions and function prototypes
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13. #ifndef _POLYLINE_H_
  14. #define _POLYLINE_H_
  15. #define INC_CLASSLIB
  16. #define INC_CONTROLS
  17. //CHAPTER24MOD
  18. #define GUIDS_FROM_TYPELIB
  19. #define INC_AUTOMATION
  20. #define INC_OLEUI
  21. #define CHAPTER24
  22. //End CHAPTER24MOD
  23. #include <inole.h>
  24. //CHAPTER24MOD
  25. #include "ipoly.h"  //From MKTYPLIB
  26. //Prevent duplicate definition of IPolylineAdviseSink10 in ipoly10.h
  27. #define OMIT_POLYLINESINK
  28. //End CHAPTER24MOD
  29. #include <ipoly10.h>
  30. #include "resource.h"
  31. //Classname
  32. #define SZCLASSPOLYLINE             TEXT("polyline")
  33. //Stream Name that holds the data
  34. #define SZSTREAM                    OLETEXT("CONTENTS")
  35. #define SZPOLYFRAMETITLE            TEXT("Polyline Figure in %s")
  36. //Magic number to add to aspects returned from IViewObject::Freeze
  37. #define FREEZE_KEY_OFFSET           0x0723
  38. #define HIMETRIC_PER_INCH           2540
  39. #define CCHPATHMAX                  256
  40. //Window extra bytes and offsets
  41. #define CBPOLYLINEWNDEXTRA          (sizeof(LONG))
  42. #define PLWL_STRUCTURE              0
  43. #define ID_HATCHWINDOW              2000
  44. //DLLPOLY.CPP
  45. int PASCAL LibMain(HINSTANCE, WORD, WORD, LPSTR);
  46. //This class factory object creates Polyline objects.
  47. class CPolylineClassFactory : public IClassFactory
  48.     {
  49.     protected:
  50.         ULONG           m_cRef;
  51.     public:
  52.         CPolylineClassFactory(void);
  53.         ~CPolylineClassFactory(void);
  54.         //IUnknown members
  55.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  56.         STDMETHODIMP_(ULONG) AddRef(void);
  57.         STDMETHODIMP_(ULONG) Release(void);
  58.         //IClassFactory members
  59.         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
  60.                                  , PPVOID);
  61.         STDMETHODIMP         LockServer(BOOL);
  62.     };
  63. typedef CPolylineClassFactory *PCPolylineClassFactory;
  64. //POLYWIN.CPP
  65. LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  66. #ifdef WIN32
  67. #define PROP_POINTER    TEXT("Pointer")
  68. #else
  69. #define PROP_SELECTOR   "Selector"
  70. #define PROP_OFFSET     "Offset"
  71. #endif
  72. BOOL APIENTRY PolyDlgProc(HWND, UINT, WPARAM, LPARAM);
  73. void CalcPolyRectInDialog(HWND, LPRECT);
  74. //Forward class references
  75. class CImpIPolyline;
  76. typedef class CImpIPolyline *PCImpIPolyline;
  77. class CImpIConnPtCont;
  78. typedef CImpIConnPtCont *PCImpIConnPtCont;
  79. class CConnectionPoint;
  80. typedef CConnectionPoint *PCConnectionPoint;
  81. class CImpIPersistStorage;
  82. typedef class CImpIPersistStorage *PCImpIPersistStorage;
  83. class CImpIPersistStreamInit;
  84. typedef class CImpIPersistStreamInit *PCImpIPersistStreamInit;
  85. class CImpIDataObject;
  86. typedef class CImpIDataObject *PCImpIDataObject;
  87. class CImpIOleObject;
  88. typedef class CImpIOleObject *PCImpIOleObject;
  89. class CImpIViewObject;
  90. typedef class CImpIViewObject *PCImpIViewObject;
  91. class CImpIRunnableObject;
  92. typedef class CImpIRunnableObject *PCImpIRunnableObject;
  93. class CImpIExternalConnection;
  94. typedef class CImpIExternalConnection *PCImpIExternalConnection;
  95. class CImpIOleInPlaceObject;
  96. typedef class CImpIOleInPlaceObject *PCImpIOleInPlaceObject;
  97. class CImpIOleInPlaceActiveObject;
  98. typedef class CImpIOleInPlaceActiveObject *PCImpIOleInPlaceActiveObject;
  99. //CHAPTER24MOD
  100. class CImpISpecifyPP;
  101. typedef CImpISpecifyPP *PCImpISpecifyPP;
  102. class CImpIProvideClassInfo;
  103. typedef CImpIProvideClassInfo *PCImpIProvideClassInfo;
  104. class CImpIDispatch;
  105. typedef CImpIDispatch *PCImpIDispatch;
  106. class CImpIPolylineControl;
  107. typedef CImpIPolylineControl *PCImpIPolylineControl;
  108. class CImpIOleControl;
  109. typedef CImpIOleControl *PCImpIOleControl;
  110. class CAdviseRouter;
  111. typedef CAdviseRouter *PCAdviseRouter;
  112. //End CHAPTER24MOD
  113. //POLYLINE.CPP
  114. class CPolyline : public IUnknown
  115.     {
  116.     friend LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM
  117.         , LPARAM);
  118.     friend class CImpIPolyline;
  119.     friend class CImpIConnPtCont;
  120.     friend class CConnectionPoint;
  121.     friend class CImpIPersistStorage;
  122.     friend class CImpIPersistStreamInit;
  123.     friend class CImpIDataObject;
  124.     friend BOOL APIENTRY PolyDlgProc(HWND, UINT, WPARAM, LPARAM);
  125.     friend class CImpIOleObject;
  126.     friend class CImpIViewObject;
  127.     friend class CImpIRunnableObject;
  128.     friend class CImpIExternalConnection;
  129.     friend class CImpIOleInPlaceObject;
  130.     friend class CImpIOleInPlaceActiveObject;
  131.     //CHAPTER24MOD
  132.     friend class CImpISpecifyPP;
  133.     friend class CImpIProvideClassInfo;
  134.     friend class CImpIDispatch;
  135.     friend class CImpIPolylineControl;
  136.     friend class CImpIOleControl;
  137.     friend class CAdviseRouter;
  138.     //End CHAPTER24MOD
  139.     protected:
  140.         HWND            m_hWnd;
  141.         HINSTANCE       m_hInst;
  142.         ULONG           m_cRef;         //Object reference count
  143.         LPUNKNOWN       m_pUnkOuter;    //Controlling Unknown
  144.         PFNDESTROYED    m_pfnDestroy;   //Function called on closure
  145.         BOOL            m_fDirty;       //Have we changed?
  146.         POLYLINEDATA    m_pl;           //Our actual data
  147.         //Contained interfaces
  148.         PCImpIPolyline          m_pImpIPolyline;
  149.         PCImpIConnPtCont        m_pImpIConnPtCont;
  150.         PCImpIPersistStorage    m_pImpIPersistStorage;
  151.         PCImpIPersistStreamInit m_pImpIPersistStreamInit;
  152.         PCImpIDataObject        m_pImpIDataObject;
  153.         /*
  154.          * Connected sink:  only one per object.  We get this
  155.          * through our connection point.
  156.          */
  157.         IPolylineAdviseSink10  *m_pAdv;
  158.         PCConnectionPoint       m_pConnPt;
  159.         PCStringTable   m_pST;          //Object strings
  160.         UINT            m_cf;           //Object clipboard format
  161.         CLSID           m_clsID;        //Current CLSID
  162.         //We have to hold these for IPersistStorage::Save
  163.         LPSTORAGE       m_pIStorage;
  164.         LPSTREAM        m_pIStream;
  165.         LPDATAADVISEHOLDER  m_pIDataAdviseHolder;
  166.         //These are default handler interfaces we use
  167.         LPUNKNOWN           m_pDefIUnknown;
  168.         LPVIEWOBJECT2       m_pDefIViewObject;
  169.         LPPERSISTSTORAGE    m_pDefIPersistStorage;
  170.         LPDATAOBJECT        m_pDefIDataObject;
  171.         //Implemented and used interfaces
  172.         PCImpIOleObject     m_pImpIOleObject;       //Implemented
  173.         LPOLEADVISEHOLDER   m_pIOleAdviseHolder;    //Used
  174.         LPOLECLIENTSITE     m_pIOleClientSite;      //Used
  175.         PCImpIViewObject    m_pImpIViewObject;      //Implemented
  176.         LPADVISESINK        m_pIAdviseSink;         //Used
  177.         DWORD               m_dwFrozenAspects;      //Freeze
  178.         DWORD               m_dwAdviseAspects;      //SetAdvise
  179.         DWORD               m_dwAdviseFlags;        //SetAdvise
  180.         POLYLINEDATA        m_plContent;            //For freezing
  181.         POLYLINEDATA        m_plThumbnail;          //For freezing
  182.         PCImpIRunnableObject m_pImpIRunnableObject; //Implemented
  183.         HWND                m_hDlg;                 //Editing window
  184.         PCImpIExternalConnection m_pImpIExternalConnection; //Implemented
  185.         BOOL                     m_fLockContainer;
  186.         DWORD                    m_dwRegROT;
  187.         LPOLEINPLACESITE            m_pIOleIPSite;
  188.         LPOLEINPLACEFRAME           m_pIOleIPFrame;
  189.         LPOLEINPLACEUIWINDOW        m_pIOleIPUIWindow;
  190.         PCImpIOleInPlaceObject       m_pImpIOleIPObject;
  191.         PCImpIOleInPlaceActiveObject m_pImpIOleIPActiveObject;
  192.         HMENU                       m_hMenuShared;
  193.         HOLEMENU                    m_hOLEMenu;
  194.         PCHatchWin                  m_pHW;
  195.         BOOL                        m_fAllowInPlace;
  196.         BOOL                        m_fUIActive;
  197.         BOOL                        m_fContainerKnowsInsideOut;
  198.         //CHAPTER24MOD
  199.         PCImpISpecifyPP             m_pImpISpecifyPP;
  200.         PCImpIProvideClassInfo      m_pImpIProvideClassInfo;
  201.         PCImpIDispatch              m_pImpIDispatch;
  202.         PCImpIPolylineControl       m_pImpIPolylineControl;
  203.         PCImpIOleControl            m_pImpIOleControl;
  204.         //Our own type lib for the object
  205.         ITypeLib                   *m_pITypeLib;
  206.         //From the container;
  207.         IOleControlSite            *m_pIOleControlSite;
  208.         IDispatch                  *m_pIDispatchAmbients;
  209.         BOOL                        m_fFreezeEvents;
  210.         CONTROLINFO                 m_ctrlInfo;
  211.         //Other ambients
  212.         BOOL                        m_fHatch;
  213.         BOOL                        m_fUIDead;
  214.         //End CHAPTER24MOD
  215.     protected:
  216.         void      PointScale(LPRECT, LPPOINTS, BOOL);
  217.         void      Draw(HDC, BOOL, BOOL, LPRECT, PPOLYLINEDATA);
  218.         HINSTANCE Instance(void);
  219.         LPTSTR    String(UINT);
  220.         void      SendAdvise(UINT);
  221.         void      RectConvertMappings(LPRECT, BOOL);
  222.         /*
  223.          * These members pulled from IPolyline now serve as a
  224.          * central store for this functionality to be used from
  225.          * other interfaces like IPersistStorage and IDataObject.
  226.          * Other interfaces later may also use them.
  227.          */
  228.         STDMETHODIMP DataSet(PPOLYLINEDATA, BOOL, BOOL);
  229.         STDMETHODIMP DataGet(PPOLYLINEDATA);
  230.         STDMETHODIMP RenderNative(HGLOBAL *);
  231.         STDMETHODIMP RenderBitmap(HBITMAP *);
  232.         STDMETHODIMP RenderMetafilePict(HGLOBAL *);
  233.     public:
  234.         CPolyline(LPUNKNOWN, PFNDESTROYED, HINSTANCE);
  235.         ~CPolyline(void);
  236.         BOOL      Init(void);
  237.         //Non-delegating object IUnknown
  238.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  239.         STDMETHODIMP_(ULONG) AddRef(void);
  240.         STDMETHODIMP_(ULONG) Release(void);
  241.         HRESULT  InPlaceActivate(LPOLECLIENTSITE, BOOL);
  242.         void     InPlaceDeactivate(void);
  243.         HRESULT  UIActivate(void);
  244.         void     UIDeactivate(void);
  245.         //CHAPTER24MOD
  246.         BOOL     AmbientGet(DISPID, VARIANT *);
  247.         void     AmbientsInitialize(DWORD);
  248.         //End CHAPTER24MOD
  249.     };
  250. typedef CPolyline *PCPolyline;
  251. //Codes for CPolyline::SendAdvise
  252. //......Code.....................Method called in CPolyline::SendAdvise
  253. #define OBJECTCODE_SAVED       0 //IOleAdviseHolder::SendOnSave
  254. #define OBJECTCODE_CLOSED      1 //IOleAdviseHolder::SendOnClose
  255. #define OBJECTCODE_RENAMED     2 //IOleAdviseHolder::SendOnRename
  256. #define OBJECTCODE_SAVEOBJECT  3 //IOleClientSite::SaveObject
  257. #define OBJECTCODE_DATACHANGED 4 //IDataAdviseHolder::SendOnDataChange
  258. #define OBJECTCODE_SHOWWINDOW  5 //IOleClientSite::OnShowWindow(TRUE)
  259. #define OBJECTCODE_HIDEWINDOW  6 //IOleClientSite::OnShowWindow(FALSE)
  260. #define OBJECTCODE_SHOWOBJECT  7 //IOleClientSite::ShowObject
  261. //CHAPTER24MOD
  262. //Flags for AmbientsInitialize
  263. enum
  264.     {
  265.     INITAMBIENT_SHOWHATCHING = 0x00000001,
  266.     INITAMBIENT_UIDEAD       = 0x00000002,
  267.     INITAMBIENT_BACKCOLOR    = 0x00000004,
  268.     INITAMBIENT_FORECOLOR    = 0x00000008,
  269.     INITAMBIENT_ALL          = 0xFFFFFFFF
  270.     };
  271. //End CHAPTER24MOD
  272. //Interface implementation contained in the Polyline.
  273. class CImpIPolyline : public IPolyline10
  274.     {
  275.     protected:
  276.         ULONG               m_cRef;      //Interface reference count
  277.         PCPolyline          m_pObj;      //Back pointer to object
  278.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  279.     public:
  280.         CImpIPolyline(PCPolyline, LPUNKNOWN);
  281.         ~CImpIPolyline(void);
  282.         //IUnknown members.
  283.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  284.         STDMETHODIMP_(ULONG) AddRef(void);
  285.         STDMETHODIMP_(ULONG) Release(void);
  286.         //Manipulation members:
  287.         STDMETHODIMP Init(HWND, LPRECT, DWORD, UINT);
  288.         STDMETHODIMP New(void);
  289.         STDMETHODIMP Undo(void);
  290.         STDMETHODIMP Window(HWND *);
  291.         STDMETHODIMP RectGet(LPRECT);
  292.         STDMETHODIMP SizeGet(LPRECT);
  293.         STDMETHODIMP RectSet(LPRECT, BOOL);
  294.         STDMETHODIMP SizeSet(LPRECT, BOOL);
  295.         STDMETHODIMP ColorSet(UINT, COLORREF, COLORREF *);
  296.         STDMETHODIMP ColorGet(UINT, COLORREF *);
  297.         STDMETHODIMP LineStyleSet(UINT, UINT *);
  298.         STDMETHODIMP LineStyleGet(UINT *);
  299.     };
  300. class CImpIConnPtCont : public IConnectionPointContainer
  301.     {
  302.     private:
  303.         ULONG               m_cRef;      //Interface ref count
  304.         PCPolyline          m_pObj;      //Back pointer to object
  305.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  306.     public:
  307.         CImpIConnPtCont(PCPolyline, LPUNKNOWN);
  308.         ~CImpIConnPtCont(void);
  309.         //IUnknown members
  310.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  311.         STDMETHODIMP_(DWORD) AddRef(void);
  312.         STDMETHODIMP_(DWORD) Release(void);
  313.         //IConnectionPointContainer members
  314.         STDMETHODIMP EnumConnectionPoints(IEnumConnectionPoints **);
  315.     STDMETHODIMP FindConnectionPoint(REFIID, IConnectionPoint **);
  316.     };
  317. /*
  318.  * This connection point will only allow one connection,
  319.  * so it always returns the same connection key.  It also
  320.  * doesn't bother to implement enumerations.
  321.  */
  322. #define CCONNMAX    1
  323. #define ADVISEKEY   72388       //Arbitrary
  324. class CConnectionPoint : public IConnectionPoint
  325.     {
  326.     private:
  327.         ULONG           m_cRef;     //Object reference count
  328.         PCPolyline      m_pObj;     //Containing object.
  329.         //CHAPTER24MOD
  330.         IID             m_iid;      //Outgoing interface
  331.         //End CHAPTER24MOD
  332.     public:
  333.         CConnectionPoint(PCPolyline);
  334.         ~CConnectionPoint(void);
  335.         //CHAPTER24MOD
  336.         void SetIID(REFIID);
  337.         //End CHAPTER24MOD
  338.         //IUnknown members
  339.         STDMETHODIMP         QueryInterface(REFIID, LPVOID *);
  340.         STDMETHODIMP_(ULONG) AddRef(void);
  341.         STDMETHODIMP_(ULONG) Release(void);
  342.         //IConnectionPoint members
  343.         STDMETHODIMP GetConnectionInterface(IID *);
  344.         STDMETHODIMP GetConnectionPointContainer
  345.             (IConnectionPointContainer **);
  346.         STDMETHODIMP Advise(LPUNKNOWN, DWORD *);
  347.         STDMETHODIMP Unadvise(DWORD);
  348.         STDMETHODIMP EnumConnections(IEnumConnections **);
  349.     };
  350. class CImpIPersistStorage : public IPersistStorage
  351.     {
  352.     protected:
  353.         ULONG               m_cRef;      //Interface reference count
  354.         PCPolyline          m_pObj;      //Back pointer to object
  355.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  356.         PSSTATE             m_psState;   //Storage state
  357.     public:
  358.         CImpIPersistStorage(PCPolyline, LPUNKNOWN);
  359.         ~CImpIPersistStorage(void);
  360.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  361.         STDMETHODIMP_(ULONG) AddRef(void);
  362.         STDMETHODIMP_(ULONG) Release(void);
  363.         STDMETHODIMP GetClassID(LPCLSID);
  364.         STDMETHODIMP IsDirty(void);
  365.         STDMETHODIMP InitNew(LPSTORAGE);
  366.         STDMETHODIMP Load(LPSTORAGE);
  367.         STDMETHODIMP Save(LPSTORAGE, BOOL);
  368.         STDMETHODIMP SaveCompleted(LPSTORAGE);
  369.         STDMETHODIMP HandsOffStorage(void);
  370.     };
  371. class CImpIPersistStreamInit : public IPersistStreamInit
  372.     {
  373.     protected:
  374.         ULONG               m_cRef;      //Interface reference count
  375.         PCPolyline          m_pObj;      //Back pointer to object
  376.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  377.     public:
  378.         CImpIPersistStreamInit(PCPolyline, LPUNKNOWN);
  379.         ~CImpIPersistStreamInit(void);
  380.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  381.         STDMETHODIMP_(ULONG) AddRef(void);
  382.         STDMETHODIMP_(ULONG) Release(void);
  383.         STDMETHODIMP GetClassID(LPCLSID);
  384.         STDMETHODIMP IsDirty(void);
  385.         STDMETHODIMP Load(LPSTREAM);
  386.         STDMETHODIMP Save(LPSTREAM, BOOL);
  387.         STDMETHODIMP GetSizeMax(ULARGE_INTEGER *);
  388.         STDMETHODIMP InitNew(void);
  389.     };
  390. //IDATAOBJ.CPP
  391. class CImpIDataObject : public IDataObject
  392.     {
  393.     private:
  394.         ULONG               m_cRef;      //Interface reference count
  395.         PCPolyline          m_pObj;      //Back pointer to object
  396.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  397.     public:
  398.         CImpIDataObject(PCPolyline, LPUNKNOWN);
  399.         ~CImpIDataObject(void);
  400.         //IUnknown members that delegate to m_pUnkOuter.
  401.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  402.         STDMETHODIMP_(ULONG) AddRef(void);
  403.         STDMETHODIMP_(ULONG) Release(void);
  404.         //IDataObject members
  405.         STDMETHODIMP GetData(LPFORMATETC, LPSTGMEDIUM);
  406.         STDMETHODIMP GetDataHere(LPFORMATETC, LPSTGMEDIUM);
  407.         STDMETHODIMP QueryGetData(LPFORMATETC);
  408.         STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC,LPFORMATETC);
  409.         STDMETHODIMP SetData(LPFORMATETC, LPSTGMEDIUM, BOOL);
  410.         STDMETHODIMP EnumFormatEtc(DWORD, LPENUMFORMATETC *);
  411.         STDMETHODIMP DAdvise(LPFORMATETC, DWORD, LPADVISESINK
  412.             , DWORD *);
  413.         STDMETHODIMP DUnadvise(DWORD);
  414.         STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *);
  415.     };
  416. //IENUMFE.CPP
  417. class CEnumFormatEtc : public IEnumFORMATETC
  418.     {
  419.     private:
  420.         ULONG           m_cRef;
  421.         LPUNKNOWN       m_pUnkRef;
  422.         ULONG           m_iCur;
  423.         ULONG           m_cfe;
  424.         LPFORMATETC     m_prgfe;
  425.     public:
  426.         CEnumFormatEtc(LPUNKNOWN, ULONG, LPFORMATETC);
  427.         ~CEnumFormatEtc(void);
  428.         //IUnknown members that delegate to m_pUnkRef.
  429.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  430.         STDMETHODIMP_(ULONG) AddRef(void);
  431.         STDMETHODIMP_(ULONG) Release(void);
  432.         //IEnumFORMATETC members
  433.         STDMETHODIMP Next(ULONG, LPFORMATETC, ULONG *);
  434.         STDMETHODIMP Skip(ULONG);
  435.         STDMETHODIMP Reset(void);
  436.         STDMETHODIMP Clone(IEnumFORMATETC **);
  437.     };
  438. typedef CEnumFormatEtc *PCEnumFormatEtc;
  439. //CHAPTER24MOD
  440. //Our own properties verb
  441. #define POLYLINEVERB_PROPERTIES     1
  442. //End CHAPTER24MOD
  443. class CImpIOleObject : public IOleObject
  444.     {
  445.     private:
  446.         ULONG           m_cRef;
  447.         PCPolyline      m_pObj;
  448.         LPUNKNOWN       m_pUnkOuter;
  449.     public:
  450.         CImpIOleObject(PCPolyline, LPUNKNOWN);
  451.         ~CImpIOleObject(void);
  452.         //IUnknown members that delegate to m_pUnkOuter.
  453.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  454.         STDMETHODIMP_(ULONG) AddRef(void);
  455.         STDMETHODIMP_(ULONG) Release(void);
  456.         //IOleObject members
  457.         STDMETHODIMP SetClientSite(LPOLECLIENTSITE);
  458.         STDMETHODIMP GetClientSite(LPOLECLIENTSITE *);
  459.         STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR);
  460.         STDMETHODIMP Close(DWORD);
  461.         STDMETHODIMP SetMoniker(DWORD, LPMONIKER);
  462.         STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);
  463.         STDMETHODIMP InitFromData(LPDATAOBJECT, BOOL, DWORD);
  464.         STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *);
  465.         STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG
  466.                          , HWND, LPCRECT);
  467.         STDMETHODIMP EnumVerbs(LPENUMOLEVERB *);
  468.         STDMETHODIMP Update(void);
  469.         STDMETHODIMP IsUpToDate(void);
  470.         STDMETHODIMP GetUserClassID(CLSID *);
  471.         STDMETHODIMP GetUserType(DWORD, LPOLESTR *);
  472.         STDMETHODIMP SetExtent(DWORD, LPSIZEL);
  473.         STDMETHODIMP GetExtent(DWORD, LPSIZEL);
  474.         STDMETHODIMP Advise(LPADVISESINK, DWORD *);
  475.         STDMETHODIMP Unadvise(DWORD);
  476.         STDMETHODIMP EnumAdvise(LPENUMSTATDATA *);
  477.         STDMETHODIMP GetMiscStatus(DWORD, DWORD *);
  478.         STDMETHODIMP SetColorScheme(LPLOGPALETTE);
  479.     };
  480. //IVIEWOBJ.CPP
  481. class CImpIViewObject : public IViewObject2
  482.     {
  483.     private:
  484.         ULONG           m_cRef;
  485.         PCPolyline      m_pObj;
  486.         LPUNKNOWN       m_pUnkOuter;
  487.     public:
  488.         CImpIViewObject(PCPolyline, LPUNKNOWN);
  489.         ~CImpIViewObject(void);
  490.         //IUnknown members that delegate to m_pUnkOuter.
  491.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  492.         STDMETHODIMP_(ULONG) AddRef(void);
  493.         STDMETHODIMP_(ULONG) Release(void);
  494.         //IViewObject members
  495.         STDMETHODIMP Draw(DWORD, LONG, LPVOID
  496.             , DVTARGETDEVICE *, HDC, HDC, LPCRECTL
  497.             , LPCRECTL, BOOL (CALLBACK *)(DWORD), DWORD);
  498.         STDMETHODIMP GetColorSet(DWORD, LONG, LPVOID
  499.             , DVTARGETDEVICE *, HDC, LPLOGPALETTE *);
  500.         STDMETHODIMP Freeze(DWORD, LONG, LPVOID, LPDWORD);
  501.         STDMETHODIMP Unfreeze(DWORD);
  502.         STDMETHODIMP SetAdvise(DWORD, DWORD, LPADVISESINK);
  503.         STDMETHODIMP GetAdvise(LPDWORD, LPDWORD, LPADVISESINK *);
  504.         STDMETHODIMP GetExtent(DWORD, LONG, DVTARGETDEVICE *
  505.             , LPSIZEL);
  506.     };
  507. class CImpIRunnableObject : public IRunnableObject
  508.     {
  509.     protected:
  510.         ULONG           m_cRef;
  511.         PCPolyline      m_pObj;
  512.         LPUNKNOWN       m_pUnkOuter;
  513.     public:
  514.         CImpIRunnableObject(PCPolyline, LPUNKNOWN);
  515.         ~CImpIRunnableObject(void);
  516.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  517.         STDMETHODIMP_(ULONG) AddRef(void);
  518.         STDMETHODIMP_(ULONG) Release(void);
  519.         STDMETHODIMP GetRunningClass(LPCLSID);
  520.         STDMETHODIMP Run(LPBINDCTX);
  521.         STDMETHODIMP_(BOOL) IsRunning(void);
  522.         STDMETHODIMP LockRunning(BOOL, BOOL);
  523.         STDMETHODIMP SetContainedObject(BOOL);
  524.     };
  525. class CImpIExternalConnection : public IExternalConnection
  526.     {
  527.     protected:
  528.         ULONG           m_cRef;
  529.         PCPolyline      m_pObj;
  530.         LPUNKNOWN       m_pUnkOuter;
  531.         DWORD           m_cLockStrong;
  532.     public:
  533.         CImpIExternalConnection(PCPolyline, LPUNKNOWN);
  534.         ~CImpIExternalConnection(void);
  535.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  536.         STDMETHODIMP_(ULONG) AddRef(void);
  537.         STDMETHODIMP_(ULONG) Release(void);
  538.         STDMETHODIMP_(DWORD) AddConnection(DWORD, DWORD);
  539.         STDMETHODIMP_(DWORD) ReleaseConnection(DWORD, DWORD, BOOL);
  540.     };
  541. class CImpIOleInPlaceObject : public IOleInPlaceObject
  542.     {
  543.     protected:
  544.         ULONG               m_cRef;
  545.         PCPolyline          m_pObj;
  546.         LPUNKNOWN           m_pUnkOuter;
  547.     public:
  548.         CImpIOleInPlaceObject(PCPolyline, LPUNKNOWN);
  549.         ~CImpIOleInPlaceObject(void);
  550.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  551.         STDMETHODIMP_(ULONG) AddRef(void);
  552.         STDMETHODIMP_(ULONG) Release(void);
  553.         STDMETHODIMP GetWindow(HWND *);
  554.         STDMETHODIMP ContextSensitiveHelp(BOOL);
  555.         STDMETHODIMP InPlaceDeactivate(void);
  556.         STDMETHODIMP UIDeactivate(void);
  557.         STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT);
  558.         STDMETHODIMP ReactivateAndUndo(void);
  559.     };
  560. class CImpIOleInPlaceActiveObject
  561.     : public IOleInPlaceActiveObject
  562.     {
  563.     protected:
  564.         ULONG               m_cRef;
  565.         PCPolyline          m_pObj;
  566.         LPUNKNOWN           m_pUnkOuter;
  567.     public:
  568.         CImpIOleInPlaceActiveObject(PCPolyline, LPUNKNOWN);
  569.         ~CImpIOleInPlaceActiveObject(void);
  570.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  571.         STDMETHODIMP_(ULONG) AddRef(void);
  572.         STDMETHODIMP_(ULONG) Release(void);
  573.         STDMETHODIMP GetWindow(HWND *);
  574.         STDMETHODIMP ContextSensitiveHelp(BOOL);
  575.         STDMETHODIMP TranslateAccelerator(LPMSG);
  576.         STDMETHODIMP OnFrameWindowActivate(BOOL);
  577.         STDMETHODIMP OnDocWindowActivate(BOOL);
  578.         STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW
  579.                          , BOOL);
  580.         STDMETHODIMP EnableModeless(BOOL);
  581.     };
  582. //CHAPTER24MOD
  583. #define CPROPPAGES   1   //Total property page count.
  584. class CImpISpecifyPP : public ISpecifyPropertyPages
  585.     {
  586.     protected:
  587.         ULONG           m_cRef;      //Interface reference count
  588.         PCPolyline      m_pObj;      //Backpointer to the object
  589.         LPUNKNOWN       m_pUnkOuter; //For delegation
  590.     public:
  591.         CImpISpecifyPP(PCPolyline, LPUNKNOWN);
  592.         ~CImpISpecifyPP(void);
  593.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  594.         STDMETHODIMP_(ULONG) AddRef(void);
  595.         STDMETHODIMP_(ULONG) Release(void);
  596.         STDMETHODIMP GetPages(CAUUID *);
  597.     };
  598. class CImpIProvideClassInfo : public IProvideClassInfo
  599.     {
  600.     protected:
  601.         ULONG           m_cRef;      //Interface reference count
  602.         PCPolyline      m_pObj;      //Backpointer to the object
  603.         LPUNKNOWN       m_pUnkOuter; //For delegation
  604.     public:
  605.         CImpIProvideClassInfo(PCPolyline, LPUNKNOWN);
  606.         ~CImpIProvideClassInfo(void);
  607.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  608.         STDMETHODIMP_(ULONG) AddRef(void);
  609.         STDMETHODIMP_(ULONG) Release(void);
  610.         STDMETHODIMP GetClassInfo(LPTYPEINFO *);
  611.     };
  612. class CImpIDispatch : public IDispatch
  613.     {
  614.     public:
  615.     private:
  616.         ULONG           m_cRef;     //For debugging
  617.         PCPolyline      m_pObj;
  618.         LPUNKNOWN       m_pUnkOuter;
  619.         ITypeInfo      *m_pITI;     //Type information
  620.     public:
  621.         CImpIDispatch(PCPolyline, LPUNKNOWN);
  622.         ~CImpIDispatch(void);
  623.         //IUnknown members that delegate to m_pUnkOuter.
  624.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  625.         STDMETHODIMP_(ULONG) AddRef(void);
  626.         STDMETHODIMP_(ULONG) Release(void);
  627.         //IDispatch members
  628.         STDMETHODIMP GetTypeInfoCount(UINT *);
  629.         STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
  630.         STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID
  631.             , DISPID *);
  632.         STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
  633.             , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  634.     };
  635. class CImpIPolylineControl : public IPolylineControl
  636.     {
  637.     protected:
  638.         ULONG               m_cRef;      //Interface reference count
  639.         PCPolyline          m_pObj;      //Back pointer to object
  640.         LPUNKNOWN           m_pUnkOuter; //Controlling unknown
  641.     public:
  642.         CImpIPolylineControl(PCPolyline, LPUNKNOWN);
  643.         ~CImpIPolylineControl(void);
  644.         //IUnknown members.
  645.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  646.         STDMETHODIMP_(ULONG) AddRef(void);
  647.         STDMETHODIMP_(ULONG) Release(void);
  648.         //Manipulation members:
  649.         STDMETHODIMP_(void)      put_BackColor(OLE_COLOR);
  650.         STDMETHODIMP_(OLE_COLOR) get_BackColor(void);
  651.         STDMETHODIMP_(void)      put_LineColor(OLE_COLOR);
  652.         STDMETHODIMP_(OLE_COLOR) get_LineColor(void);
  653.         STDMETHODIMP_(void)      put_LineStyle(short);
  654.         STDMETHODIMP_(short)     get_LineStyle(void);
  655.         STDMETHODIMP             Clear(void);
  656.         STDMETHODIMP             RemoveLastPoint(void);
  657.     };
  658. class CImpIOleControl : public IOleControl
  659.     {
  660.     protected:
  661.         ULONG           m_cRef;      //Interface reference count
  662.         PCPolyline      m_pObj;      //Backpointer to the object
  663.         LPUNKNOWN       m_pUnkOuter; //For delegation
  664.     public:
  665.         CImpIOleControl(PCPolyline, LPUNKNOWN);
  666.         ~CImpIOleControl(void);
  667.         STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  668.         STDMETHODIMP_(ULONG) AddRef(void);
  669.         STDMETHODIMP_(ULONG) Release(void);
  670.         STDMETHODIMP GetControlInfo(LPCONTROLINFO);
  671.         STDMETHODIMP OnMnemonic(LPMSG);
  672.         STDMETHODIMP OnAmbientPropertyChange(DISPID);
  673.         STDMETHODIMP FreezeEvents(BOOL);
  674.     };
  675. class CAdviseRouter : public IPolylineAdviseSink10
  676.     {
  677.     private:
  678.         ULONG       m_cRef;
  679.         PCPolyline  m_pObj;
  680.         IDispatch  *m_pIDispatch;
  681.     public:
  682.         CAdviseRouter(IDispatch *, PCPolyline);
  683.         ~CAdviseRouter(void);
  684.         void Invoke(DISPID);
  685.         //IUnknown members
  686.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  687.         STDMETHODIMP_(ULONG) AddRef(void);
  688.         STDMETHODIMP_(ULONG) Release(void);
  689.         //Advise members.
  690.         STDMETHODIMP_(void) OnPointChange(void);
  691.         STDMETHODIMP_(void) OnSizeChange(void);
  692.         STDMETHODIMP_(void) OnColorChange(void);
  693.         STDMETHODIMP_(void) OnLineStyleChange(void);
  694.     };
  695. //These values match the ID's in polyline.odl
  696. enum
  697.     {
  698.     EVENT_ONPOINTCHANGE=0,
  699.     EVENT_ONSIZECHANGE=1,
  700.     EVENT_ONCOLORCHANGE=2,
  701.     EVENT_ONLINESTYLECHANGE=3
  702.     };
  703. //End CHAPTER24MOD
  704. #endif  //_POLYLINE_H_