?? polyline.h
字號:
/*
* POLYLINE.H
* Polyline Component Chapter 19
*
* Definitions and function prototypes
*
* Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Microsoft
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _POLYLINE_H_
#define _POLYLINE_H_
#define INC_CLASSLIB
#define INC_CONTROLS
//CHAPTER19MOD
#define INC_OLEUI
#define CHAPTER19
//CHAPTER19MOD
#include <inole.h>
#include <ipoly10.h>
#include "resource.h"
//Classname
#define SZCLASSPOLYLINE TEXT("polyline")
//Stream Name that holds the data
#define SZSTREAM OLETEXT("CONTENTS")
//CHAPTER19MOD
#define SZPOLYFRAMETITLE TEXT("Polyline Figure in %s")
//Magic number to add to aspects returned from IViewObject::Freeze
#define FREEZE_KEY_OFFSET 0x0723
//End CHAPTER19MOD
#define HIMETRIC_PER_INCH 2540
#define CCHPATHMAX 256
//Window extra bytes and offsets
#define CBPOLYLINEWNDEXTRA (sizeof(LONG))
#define PLWL_STRUCTURE 0
//DLLPOLY.CPP
int PASCAL LibMain(HINSTANCE, WORD, WORD, LPSTR);
//This class factory object creates Polyline objects.
class CPolylineClassFactory : public IClassFactory
{
protected:
ULONG m_cRef;
public:
CPolylineClassFactory(void);
~CPolylineClassFactory(void);
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IClassFactory members
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID
, PPVOID);
STDMETHODIMP LockServer(BOOL);
};
typedef CPolylineClassFactory *PCPolylineClassFactory;
//POLYWIN.CPP
LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
//CHAPTER19MOD
#ifdef WIN32
#define PROP_POINTER TEXT("Pointer")
#else
#define PROP_SELECTOR "Selector"
#define PROP_OFFSET "Offset"
#endif
BOOL APIENTRY PolyDlgProc(HWND, UINT, WPARAM, LPARAM);
//End CHAPTER19MOD
//Forward class references
class CImpIPolyline;
typedef class CImpIPolyline *PCImpIPolyline;
class CImpIConnPtCont;
typedef CImpIConnPtCont *PCImpIConnPtCont;
class CConnectionPoint;
typedef CConnectionPoint *PCConnectionPoint;
class CImpIPersistStorage;
typedef class CImpIPersistStorage *PCImpIPersistStorage;
class CImpIPersistStreamInit;
typedef class CImpIPersistStreamInit *PCImpIPersistStreamInit;
class CImpIDataObject;
typedef class CImpIDataObject *PCImpIDataObject;
//CHAPTER19MOD
class CImpIOleObject;
typedef class CImpIOleObject *PCImpIOleObject;
class CImpIViewObject;
typedef class CImpIViewObject *PCImpIViewObject;
class CImpIRunnableObject;
typedef class CImpIRunnableObject *PCImpIRunnableObject;
//FORMATETC array sizes no longer necessary.
//End CHAPTER19MOD
//POLYLINE.CPP
class CPolyline : public IUnknown
{
friend LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM
, LPARAM);
friend class CImpIPolyline;
friend class CImpIConnPtCont;
friend class CConnectionPoint;
friend class CImpIPersistStorage;
friend class CImpIPersistStreamInit;
friend class CImpIDataObject;
//CHAPTER19MOD
friend BOOL APIENTRY PolyDlgProc(HWND, UINT, WPARAM, LPARAM);
friend class CImpIOleObject;
friend class CImpIViewObject;
friend class CImpIRunnableObject;
//End CHAPTER19MOD
protected:
HWND m_hWnd;
HINSTANCE m_hInst;
ULONG m_cRef; //Object reference count
LPUNKNOWN m_pUnkOuter; //Controlling Unknown
PFNDESTROYED m_pfnDestroy; //Function called on closure
BOOL m_fDirty; //Have we changed?
POLYLINEDATA m_pl; //Our actual data
//Contained interfaces
PCImpIPolyline m_pImpIPolyline;
PCImpIConnPtCont m_pImpIConnPtCont;
PCImpIPersistStorage m_pImpIPersistStorage;
PCImpIPersistStreamInit m_pImpIPersistStreamInit;
PCImpIDataObject m_pImpIDataObject;
/*
* Connected sink: only one per object. We get this
* through our connection point.
*/
IPolylineAdviseSink10 *m_pAdv;
PCConnectionPoint m_pConnPt;
PCStringTable m_pST; //Object strings
UINT m_cf; //Object clipboard format
CLSID m_clsID; //Current CLSID
//We have to hold these for IPersistStorage::Save
LPSTORAGE m_pIStorage;
LPSTREAM m_pIStream;
LPDATAADVISEHOLDER m_pIDataAdviseHolder;
//CHAPTER19MOD
//FORMATETC arrays no longer necessary.
//These are default handler interfaces we use
LPUNKNOWN m_pDefIUnknown;
LPVIEWOBJECT2 m_pDefIViewObject;
LPPERSISTSTORAGE m_pDefIPersistStorage;
LPDATAOBJECT m_pDefIDataObject;
//Implemented and used interfaces
PCImpIOleObject m_pImpIOleObject; //Implemented
LPOLEADVISEHOLDER m_pIOleAdviseHolder; //Used
LPOLECLIENTSITE m_pIOleClientSite; //Used
PCImpIViewObject m_pImpIViewObject; //Implemented
LPADVISESINK m_pIAdviseSink; //Used
DWORD m_dwFrozenAspects; //Freeze
DWORD m_dwAdviseAspects; //SetAdvise
DWORD m_dwAdviseFlags; //SetAdvise
POLYLINEDATA m_plContent; //For freezing
POLYLINEDATA m_plThumbnail; //For freezing
PCImpIRunnableObject m_pImpIRunnableObject; //Implemented
HWND m_hDlg; //Editing window
//End CHAPTER19MOD
protected:
void PointScale(LPRECT, LPPOINTS, BOOL);
//CHAPTER19MOD
void Draw(HDC, BOOL, BOOL, LPRECT, PPOLYLINEDATA);
HINSTANCE Instance(void);
LPTSTR String(UINT);
void SendAdvise(UINT);
//End CHAPTER19MOD
void RectConvertMappings(LPRECT, BOOL);
/*
* These members pulled from IPolyline now serve as a
* central store for this functionality to be used from
* other interfaces like IPersistStorage and IDataObject.
* Other interfaces later may also use them.
*/
STDMETHODIMP DataSet(PPOLYLINEDATA, BOOL, BOOL);
STDMETHODIMP DataGet(PPOLYLINEDATA);
STDMETHODIMP RenderNative(HGLOBAL *);
STDMETHODIMP RenderBitmap(HBITMAP *);
STDMETHODIMP RenderMetafilePict(HGLOBAL *);
public:
CPolyline(LPUNKNOWN, PFNDESTROYED, HINSTANCE);
~CPolyline(void);
BOOL Init(void);
//Non-delegating object IUnknown
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
};
typedef CPolyline *PCPolyline;
//CHAPTER19MOD
//Codes for CPolyline::SendAdvise
//......Code.....................Method called in CPolyline::SendAdvise
#define OBJECTCODE_SAVED 0 //IOleAdviseHolder::SendOnSave
#define OBJECTCODE_CLOSED 1 //IOleAdviseHolder::SendOnClose
#define OBJECTCODE_RENAMED 2 //IOleAdviseHolder::SendOnRename
#define OBJECTCODE_SAVEOBJECT 3 //IOleClientSite::SaveObject
#define OBJECTCODE_DATACHANGED 4 //IDataAdviseHolder::SendOnDataChange
#define OBJECTCODE_SHOWWINDOW 5 //IOleClientSite::OnShowWindow(TRUE)
#define OBJECTCODE_HIDEWINDOW 6 //IOleClientSite::OnShowWindow(FALSE)
#define OBJECTCODE_SHOWOBJECT 7 //IOleClientSite::ShowObject
//End CHAPTER19MOD
//Interface implementation contained in the Polyline.
class CImpIPolyline : public IPolyline10
{
protected:
ULONG m_cRef; //Interface reference count
PCPolyline m_pObj; //Back pointer to object
LPUNKNOWN m_pUnkOuter; //Controlling unknown
public:
CImpIPolyline(PCPolyline, LPUNKNOWN);
~CImpIPolyline(void);
//IUnknown members.
STDMETHODIMP QueryInterface(REFIID, PPVOID);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//Manipulation members:
STDMETHODIMP Init(HWND, LPRECT, DWORD, UINT);
STDMETHODIMP New(void);
STDMETHODIMP Undo(void);
STDMETHODIMP Window(HWND *);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -