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 / chap12 / patron / patron.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  4.4 KB  |  175 lines

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