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

  1. /*
  2.  * COSMO.H
  3.  * Cosmo Chapter 12
  4.  *
  5.  * Single include file that pulls in everything needed for other
  6.  * source files in the Cosmo 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 _COSMO_H_
  17. #define _COSMO_H_
  18.  
  19. #define INC_CLASSLIB
  20. //CHAPTER12MOD
  21. #define CHAPTER12
  22. //End CHAPTER12MOD
  23. #include <inole.h>
  24. #include "resource.h"
  25.  
  26. //Get the editor window information.
  27. #include "polyline.h"
  28.  
  29.  
  30.  
  31. //COSMO.CPP:  Frame object that creates a main window
  32.  
  33. class CCosmoFrame : public CFrame
  34.     {
  35.     private:
  36.         HBITMAP         m_hBmpLines[5];     //Menu item bitmaps
  37.         UINT            m_uIDCurLine;       //Current line selection
  38.         BOOL            m_fInitialized;     //Did OleInitalize work?
  39.  
  40.         //CHAPTER12MOD
  41.         //For locking DATATRAN.DLL class factory
  42.         LPCLASSFACTORY  m_pIClassDataTran;
  43.         //End CHAPTER12MOD
  44.  
  45.     protected:
  46.         //Overridable for creating a CClient for this frame
  47.         virtual PCClient  CreateCClient(void);
  48.  
  49.         virtual BOOL      RegisterAllClasses(void);
  50.         virtual BOOL      PreShowInit(void);
  51.         virtual UINT      CreateToolbar(void);
  52.  
  53.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  54.         virtual void      OnDocumentDataChange(PCDocument);
  55.         virtual void      OnDocumentActivate(PCDocument);
  56.  
  57.         //New for this class
  58.         virtual void      CreateLineMenu(void);
  59.  
  60.     public:
  61.         CCosmoFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  62.         virtual ~CCosmoFrame(void);
  63.  
  64.         //Overrides
  65.         virtual BOOL      Init(PFRAMEINIT);
  66.         virtual void      UpdateMenus(HMENU, UINT);
  67.         virtual void      UpdateToolbar(void);
  68.  
  69.         //New for this class
  70.         virtual void      CheckLineSelection(UINT);
  71.     };
  72.  
  73.  
  74. typedef CCosmoFrame *PCCosmoFrame;
  75.  
  76.  
  77.  
  78.  
  79.  
  80. //CLIENT.CPP
  81.  
  82. /*
  83.  * The only reason we have a derived class here is to override
  84.  * CreateCDocument so we can create our own type as well as
  85.  * overriding NewDocument to perform one other piece of work once
  86.  * the document's been created.
  87.  */
  88.  
  89. class CCosmoClient : public CClient
  90.     {
  91.     protected:
  92.         //Overridable for creating a new CDocument
  93.         virtual PCDocument CreateCDocument(void);
  94.  
  95.     public:
  96.         CCosmoClient(HINSTANCE, PCFrame);
  97.         virtual ~CCosmoClient(void);
  98.  
  99.         virtual PCDocument NewDocument(BOOL);
  100.     };
  101.  
  102.  
  103. typedef CCosmoClient *PCCosmoClient;
  104.  
  105.  
  106.  
  107.  
  108. //DOCUMENT.CPP
  109.  
  110. //Constant ID for the window polyline that lives in a document
  111. #define ID_POLYLINE         10
  112.  
  113.  
  114. class CCosmoDoc : public CDocument
  115.     {
  116.     friend class CPolylineAdviseSink;
  117.  
  118.     protected:
  119.         UINT                    m_uPrevSize;    //Last WM_SIZE wParam
  120.         LONG                    m_lVer;         //Loaded Polyline ver
  121.  
  122.         PCPolyline              m_pPL;          //Polyline window here
  123.         PCPolylineAdviseSink    m_pPLAdv;       //Advises from Polyline
  124.  
  125.     protected:
  126.         virtual BOOL     FMessageHook(HWND, UINT, WPARAM, LPARAM
  127.             , LRESULT *);
  128.  
  129.         //CHAPTER12MOD
  130.         virtual BOOL     FQueryPasteFromData(LPDATAOBJECT);
  131.         virtual BOOL     PasteFromData(LPDATAOBJECT);
  132.         //End CHAPTER12MOD
  133.  
  134.     public:
  135.         CCosmoDoc(HINSTANCE, PCFrame, PCDocumentAdviseSink);
  136.         virtual ~CCosmoDoc(void);
  137.  
  138.         virtual BOOL     Init(PDOCUMENTINIT);
  139.  
  140.         virtual void     Clear(void);
  141.  
  142.         virtual UINT     Load(BOOL, LPTSTR);
  143.         virtual UINT     Save(UINT, LPTSTR);
  144.  
  145.         virtual void     Undo(void);
  146.         virtual BOOL     Clip(HWND, BOOL);
  147.         virtual HGLOBAL  RenderFormat(UINT);
  148.         virtual BOOL     FQueryPaste(void);
  149.         virtual BOOL     Paste(HWND);
  150.  
  151.         virtual COLORREF ColorSet(UINT, COLORREF);
  152.         virtual COLORREF ColorGet(UINT);
  153.  
  154.         virtual UINT     LineStyleSet(UINT);
  155.         virtual UINT     LineStyleGet(void);
  156.     };
  157.  
  158. typedef CCosmoDoc *PCCosmoDoc;
  159.  
  160.  
  161. //These color indices wrap the polyline definitions
  162. #define DOCCOLOR_BACKGROUND             POLYLINECOLOR_BACKGROUND
  163. #define DOCCOLOR_LINE                   POLYLINECOLOR_LINE
  164.  
  165.  
  166.  
  167. #endif //_COSMO_H_
  168.