home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap01 / patron / pages.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  141 lines

  1. /*
  2.  * PAGES.H
  3.  * Patron Chapter 1
  4.  *
  5.  * Definitions and function prototypes for the Pages window control.
  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.  
  14.  
  15. #ifndef _PAGES_H_
  16. #define _PAGES_H_
  17.  
  18. //Versioning.
  19. #define VERSIONMAJOR                2
  20. #define VERSIONMINOR                0
  21. #define VERSIONCURRENT              0x00020000
  22.  
  23. //Classname
  24. #define SZCLASSPAGES                TEXT("pages")
  25.  
  26. #define HIMETRIC_PER_INCH           2540
  27. #define LOMETRIC_PER_INCH           254
  28. #define LOMETRIC_BORDER             60          //Border around page
  29.  
  30.  
  31. //Window extra bytes and offsets
  32. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  33. #define PAGEWL_STRUCTURE            0
  34.  
  35.  
  36. /*
  37.  * Page class describing an individual page and what things it
  38.  * contains.
  39.  *
  40.  * A DWORD is used to identify this page as the name of the storage
  41.  * is the string form of this ID.  If we added a page every second,
  42.  * it would take 136 years to overrun this counter, so we can
  43.  * get away with saving it persistently.  I hope this software is
  44.  * obsolete by then.
  45.  */
  46.  
  47. class CPage
  48.     {
  49.     private:
  50.         DWORD       m_dwID;             //Persistent identifier
  51.  
  52.     public:
  53.         CPage(DWORD);
  54.         ~CPage(void);
  55.  
  56.         DWORD           GetID(void);
  57.     };
  58.  
  59. typedef CPage *PCPage;
  60.  
  61.  
  62.  
  63. //PRINT.CPP
  64. BOOL    APIENTRY AbortProc(HDC, int);
  65. BOOL    APIENTRY PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  66.  
  67.  
  68. //PAGEWIN.CPP
  69. LRESULT APIENTRY PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  70. void             RectConvertMappings(LPRECT, HDC, BOOL);
  71.  
  72.  
  73. class CPages : public CWindow
  74.     {
  75.     friend LRESULT APIENTRY PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  76.     friend BOOL    APIENTRY PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  77.  
  78.     private:
  79.         UINT        m_iPageCur;             //Current page
  80.         UINT        m_cPages;               //Number of pages
  81.  
  82.         HWND        m_hWndPageList;         //Listbox with page list
  83.         HFONT       m_hFont;                //Page font
  84.         BOOL        m_fSystemFont;          //m_hFont system object?
  85.  
  86.         UINT        m_cx;                   //Page size in LOMETRIC
  87.         UINT        m_cy;
  88.  
  89.         UINT        m_xMarginLeft;          //Unusable margins,
  90.         UINT        m_xMarginRight;         //in LOMETRIC
  91.         UINT        m_yMarginTop;
  92.         UINT        m_yMarginBottom;
  93.  
  94.         UINT        m_xPos;                 //Viewport scroll pos,
  95.         UINT        m_yPos;                 //both in *PIXELS*
  96.  
  97.         DWORD       m_dwIDNext;             //Next ID for a page.
  98.  
  99.         HGLOBAL     m_hDevMode;             //Current DevMode config
  100.  
  101.         TCHAR       m_szDriver[CCHDEVICENAME];
  102.         TCHAR       m_szDevice[CCHDEVICENAME];
  103.         TCHAR       m_szPort[CCHDEVICENAME];
  104.  
  105.     private:
  106.         void        Draw(HDC, BOOL, BOOL);
  107.         void        UpdateScrollRanges(void);
  108.         BOOL        ConfigureForDevice(void);
  109.         BOOL        PageGet(UINT, PCPage *, BOOL);
  110.         BOOL        PageAdd(UINT, DWORD, BOOL);
  111.  
  112.     public:
  113.         CPages(HINSTANCE);
  114.         ~CPages(void);
  115.  
  116.         BOOL        Init(HWND, LPRECT, DWORD, UINT, LPVOID);
  117.  
  118.         void        New(void);
  119.         BOOL        Print(HDC, LPTSTR, DWORD, UINT, UINT, UINT);
  120.  
  121.         void        RectGet(LPRECT);
  122.         void        RectSet(LPRECT, BOOL);
  123.         void        SizeGet(LPRECT);
  124.         void        SizeSet(LPRECT, BOOL);
  125.  
  126.         PCPage      ActivePage(void);
  127.         UINT        PageInsert(UINT);
  128.         UINT        PageDelete(UINT);
  129.         UINT        CurPageGet(void);
  130.         UINT        CurPageSet(UINT);
  131.         UINT        NumPagesGet(void);
  132.  
  133.         BOOL        DevModeSet(HGLOBAL, HGLOBAL);
  134.         HGLOBAL     DevModeGet(void);
  135.     };
  136.  
  137. typedef CPages *PCPages;
  138.  
  139.  
  140. #endif  //_PAGES_H_
  141.