home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch34 / draw / draw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-09  |  3.3 KB  |  132 lines

  1. // draw.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "draw.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "drawdoc.h"
  9. #include "drawview.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CDrawApp
  18.  
  19. BEGIN_MESSAGE_MAP(CDrawApp, CWinApp)
  20.     //{{AFX_MSG_MAP(CDrawApp)
  21.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code!
  24.     //}}AFX_MSG_MAP
  25.     // Standard file based document commands
  26.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  27.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  28.     // Standard print setup command
  29.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDrawApp construction
  34.  
  35. CDrawApp::CDrawApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CDrawApp object
  43.  
  44. CDrawApp NEAR theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CDrawApp initialization
  48.  
  49. BOOL CDrawApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.     // If you are not using these features and wish to reduce the size
  53.     //  of your final executable, you should remove from the following
  54.     //  the specific initialization routines you do not need.
  55.  
  56.     SetDialogBkColor();        // Set dialog background color to gray
  57.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  58.  
  59.     // Register the application's document templates.  Document templates
  60.     //  serve as the connection between documents, frame windows and views.
  61.  
  62.     CSingleDocTemplate* pDocTemplate;
  63.     pDocTemplate = new CSingleDocTemplate(
  64.         IDR_MAINFRAME,
  65.         RUNTIME_CLASS(CDrawDoc),
  66.         RUNTIME_CLASS(CMainFrame),     // main SDI frame window
  67.         RUNTIME_CLASS(CDrawView));
  68.     AddDocTemplate(pDocTemplate);
  69.  
  70.     // create a new (empty) document
  71.     OnFileNew();
  72.  
  73.     if (m_lpCmdLine[0] != '\0')
  74.     {
  75.         // TODO: add command line processing here
  76.     }
  77.  
  78.  
  79.     return TRUE;
  80. }
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CAboutDlg dialog used for App About
  84.  
  85. class CAboutDlg : public CDialog
  86. {
  87. public:
  88.     CAboutDlg();
  89.  
  90. // Dialog Data
  91.     //{{AFX_DATA(CAboutDlg)
  92.     enum { IDD = IDD_ABOUTBOX };
  93.     //}}AFX_DATA
  94.  
  95. // Implementation
  96. protected:
  97.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  98.     //{{AFX_MSG(CAboutDlg)
  99.         // No message handlers
  100.     //}}AFX_MSG
  101.     DECLARE_MESSAGE_MAP()
  102. };
  103.  
  104. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  105. {
  106.     //{{AFX_DATA_INIT(CAboutDlg)
  107.     //}}AFX_DATA_INIT
  108. }
  109.  
  110. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  111. {
  112.     CDialog::DoDataExchange(pDX);
  113.     //{{AFX_DATA_MAP(CAboutDlg)
  114.     //}}AFX_DATA_MAP
  115. }
  116.  
  117. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  118.     //{{AFX_MSG_MAP(CAboutDlg)
  119.         // No message handlers
  120.     //}}AFX_MSG_MAP
  121. END_MESSAGE_MAP()
  122.  
  123. // App command to run the dialog
  124. void CDrawApp::OnAppAbout()
  125. {
  126.     CAboutDlg aboutDlg;
  127.     aboutDlg.DoModal();
  128. }
  129.  
  130. /////////////////////////////////////////////////////////////////////////////
  131. // CDrawApp commands
  132.