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

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * POLYLINE.H
  3.  * Cosmo Chapter 14
  4.  *
  5.  * Definitions and function prototypes for the PolyLine window
  6.  * class that can be treated like its own control.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14. #ifndef _POLYLINE_H_
  15. #define _POLYLINE_H_
  16. //Versioning.
  17. #define VERSIONMAJOR                2
  18. #define VERSIONMINOR                0
  19. #define VERSIONCURRENT              0x00020000
  20. //Classname
  21. #define SZCLASSPOLYLINE             TEXT("polyline")
  22. //Stream Name that holds the data
  23. #define SZSTREAM                    OLETEXT("CONTENTS")
  24. #define HIMETRIC_PER_INCH           2540
  25. #define CPOLYLINEPOINTS             20
  26. //Window extra bytes and offsets
  27. #define CBPOLYLINEWNDEXTRA          (sizeof(LONG))
  28. #define PLWL_STRUCTURE              0
  29. //Version 2.0 Polyline Structure
  30. typedef struct tagPOLYLINEDATA
  31.     {
  32.     WORD        wVerMaj;                //Major version number.
  33.     WORD        wVerMin;                //Minor version number.
  34.     WORD        cPoints;                //Number of points.
  35.     short       fReserved;              //Obsolete from v1.0
  36.     RECTS       rc;                     //Rectangle of this figure
  37.     POINTS      rgpt[CPOLYLINEPOINTS];  //Points (0-32767 grid)
  38.     //Version 2.0 additions
  39.     COLORREF    rgbBackground;          //Background color
  40.     COLORREF    rgbLine;                //Line color
  41.     short       iLineStyle;             //Line style
  42.     } POLYLINEDATA, *PPOLYLINEDATA;
  43. #define CBPOLYLINEDATA   sizeof(POLYLINEDATA)
  44. #define CBPOLYLINEDATA20 sizeof(POLYLINEDATA)
  45. //Version 1.0 Polyline Structure
  46. typedef struct tagPOLYLINEDATA10
  47.     {
  48.     WORD        wVerMaj;                //Major version number.
  49.     WORD        wVerMin;                //Minor version number.
  50.     WORD        cPoints;                //Number of points.
  51.     short       fDrawEntire;            //Flag to draw entire figure
  52.     RECTS       rc;                     //Rectangle of this figure
  53.     POINTS      rgpt[CPOLYLINEPOINTS];  //Points (scaled to rc)
  54.     } POLYLINEDATA10, *PPOLYLINEDATA10;
  55. #define CBPOLYLINEDATA10 sizeof(POLYLINEDATA10)
  56. //POLYWIN.CPP
  57. LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  58. class CPolyline : public CWindow
  59.     {
  60.     friend LRESULT APIENTRY PolylineWndProc(HWND, UINT, WPARAM
  61.         , LPARAM);
  62.     private:
  63.         POLYLINEDATA   m_pl;
  64.         class CPolylineAdviseSink * m_pAdv;
  65.     private:
  66.         HFILE     OpenFileW(LPTSTR, LPOFSTRUCT, UINT);
  67.         void      Draw(HDC, BOOL, BOOL);
  68.         void      RectConvertMappings(LPRECT, BOOL);
  69.     public:
  70.         CPolyline(HINSTANCE);
  71.         ~CPolyline(void);
  72.         BOOL      Init(HWND, LPRECT, DWORD, UINT
  73.             , class CPolylineAdviseSink *);
  74.         //CHAPTER14MOD
  75.         //Needed to be public for OLE Automation
  76.         void      PointScale(LPRECT, LPPOINTS, BOOL);
  77.         //End CHAPTER14MOD
  78.         void      New(void);
  79.         BOOL      Undo(void);
  80.         //File functions
  81.         LONG      ReadFromStorage(LPSTORAGE);
  82.         LONG      WriteToStorage(LPSTORAGE, LONG);
  83.         LONG      ReadFromFile(LPTSTR);
  84.         LONG      WriteToFile(LPTSTR, LONG);
  85.         //Data transfer functions
  86.         LONG      DataSet(PPOLYLINEDATA, BOOL, BOOL);
  87.         LONG      DataGet(PPOLYLINEDATA, LONG);
  88.         LONG      DataSetMem(HGLOBAL, BOOL, BOOL, BOOL);
  89.         LONG      DataGetMem(LONG, HGLOBAL *);
  90.         HBITMAP   RenderBitmap(void);
  91.         HMETAFILE RenderMetafile(void);
  92.         HGLOBAL   RenderMetafilePict(void);
  93.         void      RectGet(LPRECT);
  94.         void      SizeGet(LPRECT);
  95.         void      RectSet(LPRECT, BOOL);
  96.         void      SizeSet(LPRECT, BOOL);
  97.         COLORREF  ColorSet(UINT, COLORREF);
  98.         COLORREF  ColorGet(UINT);
  99.         UINT      LineStyleSet(UINT);
  100.         UINT      LineStyleGet(void);
  101.     };
  102. typedef CPolyline *PCPolyline;
  103. //Error values for data transfer functions
  104. #define POLYLINE_E_NONE                    0
  105. #define POLYLINE_E_UNSUPPORTEDVERSION      -1
  106. #define POLYLINE_E_INVALIDPOINTER          -2
  107. #define POLYLINE_E_READFAILURE             -3
  108. #define POLYLINE_E_WRITEFAILURE            -4
  109. class CPolylineAdviseSink
  110.     {
  111.     private:
  112.         LPVOID      m_pv;           //Customizable structure
  113.     public:
  114.         CPolylineAdviseSink(LPVOID);
  115.         ~CPolylineAdviseSink(void);
  116.         void OnPointChange(void);
  117.         void OnSizeChange(void);
  118.         void OnDataChange(void);
  119.         void OnColorChange(void);
  120.         void OnLineStyleChange(void);
  121.     };
  122. typedef CPolylineAdviseSink *PCPolylineAdviseSink;
  123. //Color indices for color messages
  124. #define POLYLINECOLOR_BACKGROUND    0
  125. #define POLYLINECOLOR_LINE          1
  126. #endif  //_POLYLINE_H_