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 / chap07 / patron / patron.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  152 lines

  1. /*
  2.  * PATRON.H
  3.  * Patron Chapter 7
  4.  *
  5.  * Single include file that pulls in everything needed for other
  6.  * source files in the application.
  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.  
  15.  
  16. #ifndef _PATRON_H_
  17. #define _PATRON_H_
  18.  
  19. #define INC_CLASSLIB
  20. //CHAPTER7MOD
  21. #define INC_OLE2
  22. #define CHAPTER7
  23. //End CHAPTER7MOD
  24. #include <inole.h>
  25. #include "resource.h"
  26.  
  27. //Get editor window information
  28. #include "pages.h"
  29.  
  30.  
  31. /*
  32.  * UINT value such that adding one produces zero.  Portable to Win32.
  33.  * This is used to represent a non-existent zero-based UINT value
  34.  */
  35. #define NOVALUE                     ((UINT)-1)
  36.  
  37.  
  38. //PATRON.CPP:  Frame object that creates a main window
  39.  
  40. class CPatronFrame : public CFrame
  41.     {
  42.     //CHAPTER7MOD
  43.     private:
  44.         BOOL            m_fInitialized;     //OleInitialize worked
  45.     //End CHAPTER7MOD
  46.  
  47.     protected:
  48.         //Overridable for creating a CPatronClient
  49.         virtual PCClient    CreateCClient(void);
  50.  
  51.         virtual BOOL        RegisterAllClasses(void);
  52.         virtual UINT        CreateToolbar(void);
  53.         virtual LRESULT     OnCommand(HWND, WPARAM, LPARAM);
  54.  
  55.     public:
  56.         CPatronFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  57.         virtual ~CPatronFrame(void);
  58.  
  59.         //Overrides
  60.         //CHAPTER7MOD
  61.         virtual BOOL        Init(PFRAMEINIT);
  62.         //End CHAPTER7MOD
  63.  
  64.         virtual void        UpdateMenus(HMENU, UINT);
  65.         virtual void        UpdateToolbar(void);
  66.  
  67.     };
  68.  
  69.  
  70. typedef CPatronFrame *PCPatronFrame;
  71.  
  72.  
  73.  
  74.  
  75.  
  76. //CLIENT.CPP
  77.  
  78. /*
  79.  * The only reason we have a derived class here is to override
  80.  * CreateCDocument so we can create our own type as well as
  81.  * overriding NewDocument to perform one other piece of work once
  82.  * the document's been created.
  83.  */
  84.  
  85. class CPatronClient : public CClient
  86.     {
  87.     protected:
  88.         //Overridable for creating a new CDocument
  89.         virtual PCDocument CreateCDocument(void);
  90.  
  91.     public:
  92.         CPatronClient(HINSTANCE, PCFrame);
  93.         virtual ~CPatronClient(void);
  94.     };
  95.  
  96.  
  97. typedef CPatronClient *PCPatronClient;
  98.  
  99.  
  100.  
  101.  
  102. //DOCUMENT.CPP
  103.  
  104. //Constant ID for the pages window that lives in a document window
  105. #define ID_PAGES            723
  106.  
  107.  
  108. class CPatronDoc : public CDocument
  109.     {
  110.     protected:
  111.         LONG            m_lVer;         //Loaded data version
  112.         PCPages         m_pPG;          //Pages window in us
  113.  
  114.         //CHAPTER7MOD
  115.         LPSTORAGE       m_pIStorage;    //Root storage for document
  116.         //End CHAPTER7MOD
  117.  
  118.     protected:
  119.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM
  120.             , LRESULT *);
  121.  
  122.     public:
  123.         CPatronDoc(HINSTANCE, PCFrame, PCDocumentAdviseSink);
  124.         virtual ~CPatronDoc(void);
  125.  
  126.         virtual BOOL    Init(PDOCUMENTINIT);
  127.         virtual void    Clear(void);
  128.  
  129.         virtual UINT    Load(BOOL, LPTSTR);
  130.         //CHAPTER7MOD
  131.         virtual UINT    Save(UINT, LPTSTR);
  132.         //End CHAPTER7MOD
  133.  
  134.         virtual BOOL    Print(HWND);
  135.         virtual UINT    PrinterSetup(HWND, BOOL);
  136.  
  137.         virtual UINT    NewPage(void);
  138.         virtual UINT    DeletePage(void);
  139.         virtual UINT    NextPage(void);
  140.         virtual UINT    PreviousPage(void);
  141.         virtual UINT    FirstPage(void);
  142.         virtual UINT    LastPage(void);
  143.     };
  144.  
  145. typedef CPatronDoc *PCPatronDoc;
  146.  
  147. //Hook for Print Dialog to hide Setup... button
  148. UINT CALLBACK PrintDlgHook(HWND, UINT, WPARAM, LPARAM);
  149.  
  150.  
  151. #endif //_PATRON_H_
  152.