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 / chap14 / cosmo / client.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.9 KB  |  147 lines

  1. /*
  2.  * CLIENT.CPP
  3.  * Cosmo Chapter 14
  4.  *
  5.  * Implementation of the CCosmoClient class that just makes sure
  6.  * we get a CCosmoDoc on doc creation and that we initialize fully.
  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. #include "cosmo.h"
  17.  
  18.  
  19. /*
  20.  * CCosmoClient::CCosmoClient
  21.  * CCosmoClient::~CCosmoClient
  22.  *
  23.  * Constructor Parameters:
  24.  *  hInst           HINSTANCE of the application.
  25.  *  pFR             PCFrame to the frame object.
  26.  */
  27.  
  28. CCosmoClient::CCosmoClient(HINSTANCE hInst, PCFrame pFR)
  29.     : CClient(hInst, pFR)
  30.     {
  31.     m_pAutoFigures=NULL;
  32.     return;
  33.     }
  34.  
  35.  
  36. CCosmoClient::~CCosmoClient(void)
  37.     {
  38.     //CHAPTER14MOD
  39.     DeleteInterfaceImp(m_pAutoFigures);
  40.     //End CHAPTER14MOD
  41.     return;
  42.     }
  43.  
  44.  
  45.  
  46. /*
  47.  * CCosmoClient::Init
  48.  *
  49.  * Purpose:
  50.  *  Performs default initialization then creates the Figures
  51.  *  collection object stored here.
  52.  *
  53.  * Return Value:
  54.  *  BOOL            TRUE if the function succeeded, FALSE otherwise.
  55.  */
  56.  
  57. BOOL CCosmoClient::Init(HMENU hMenuWindow, LPRECT pRect)
  58.     {
  59.     if (!CClient::Init(hMenuWindow, pRect))
  60.         return FALSE;
  61.  
  62.     //Create the 'figures' collection.
  63.     m_pAutoFigures=new CAutoFigures(this);
  64.  
  65.     if (NULL==m_pAutoFigures)
  66.         return FALSE;
  67.  
  68.     if (!m_pAutoFigures->Init(FALSE))
  69.         return FALSE;
  70.  
  71.     return TRUE;
  72.     }
  73.  
  74.  
  75.  
  76.  
  77. /*
  78.  * CCosmoClient::CreateCDocument
  79.  *
  80.  * Purpose:
  81.  *  Constructs a new document specific to the application.
  82.  *
  83.  * Parameters:
  84.  *  None
  85.  *
  86.  * Return Value:
  87.  *  PCDocument      Pointer to the new document object.
  88.  */
  89.  
  90. PCDocument CCosmoClient::CreateCDocument(void)
  91.     {
  92.     return (PCDocument)(new CCosmoDoc(m_hInst, m_pFR, m_pAdv));
  93.     }
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. /*
  102.  * CCosmoClient::NewDocument
  103.  *
  104.  * Purpose:
  105.  *  Small override of the CClient::NewDocument that we have just
  106.  *  to check the initial line selection on new document creation.
  107.  *
  108.  * Parameters:
  109.  *  fVisible        BOOL indicating if the document is to be
  110.  *                  visible or not.
  111.  *
  112.  * Return Value:
  113.  *  PCDocument      Pointer to the new document object.
  114.  */
  115.  
  116. PCDocument CCosmoClient::NewDocument(BOOL fVisible)
  117.     {
  118.     PCDocument  pDoc;
  119.  
  120.     //Perform default NewDocument first
  121.     pDoc=CClient::NewDocument(fVisible);
  122.  
  123.     //We know that m_pFR is actually a CCosmoFrame, so type is safe.
  124.     ((PCCosmoFrame)m_pFR)->CheckLineSelection(IDM_LINESOLID);
  125.  
  126.     return pDoc;
  127.     }
  128.  
  129.  
  130.  
  131. //CHAPTER14MOD
  132. /*
  133.  * CCosmoClient::AutoFigures
  134.  *
  135.  * Purpose:
  136.  *  Returns the 'figures' collection automation object pointer
  137.  *
  138.  * Return Value:
  139.  *  PCAutoFigures   Pointer to the figures collection object
  140.  */
  141.  
  142. PCAutoFigures CCosmoClient::AutoFigures(void)
  143.     {
  144.     return m_pAutoFigures;
  145.     }
  146. //End CHAPTER14MOD
  147.