home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c03 / lab01 / ex01 / lab3_1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  4.1 KB  |  151 lines

  1. // Lab3_1.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Lab3_1.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "Lab3_1Doc.h"
  9. #include "Lab3_1View.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CLab3_1App
  19.  
  20. BEGIN_MESSAGE_MAP(CLab3_1App, CWinApp)
  21.     //{{AFX_MSG_MAP(CLab3_1App)
  22.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard file based document commands
  27.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29.     // Standard print setup command
  30.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CLab3_1App construction
  35.  
  36. CLab3_1App::CLab3_1App()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CLab3_1App object
  44.  
  45. CLab3_1App theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CLab3_1App initialization
  49.  
  50. BOOL CLab3_1App::InitInstance()
  51. {
  52.     // Standard initialization
  53.     // If you are not using these features and wish to reduce the size
  54.     //  of your final executable, you should remove from the following
  55.     //  the specific initialization routines you do not need.
  56.  
  57. #ifdef _AFXDLL
  58.     Enable3dControls();            // Call this when using MFC in a shared DLL
  59. #else
  60.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  61. #endif
  62.  
  63.     // Change the registry key under which our settings are stored.
  64.     // You should modify this string to be something appropriate
  65.     // such as the name of your company or organization.
  66.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  67.  
  68.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  69.  
  70.     // Register the application's document templates.  Document templates
  71.     //  serve as the connection between documents, frame windows and views.
  72.  
  73.     CSingleDocTemplate* pDocTemplate;
  74.     pDocTemplate = new CSingleDocTemplate(
  75.         IDR_MAINFRAME,
  76.         RUNTIME_CLASS(CLab3_1Doc),
  77.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  78.         RUNTIME_CLASS(CLab3_1View));
  79.     AddDocTemplate(pDocTemplate);
  80.  
  81.     // Parse command line for standard shell commands, DDE, file open
  82.     CCommandLineInfo cmdInfo;
  83.     ParseCommandLine(cmdInfo);
  84.  
  85.     // Dispatch commands specified on the command line
  86.     if (!ProcessShellCommand(cmdInfo))
  87.         return FALSE;
  88.  
  89.     // The one and only window has been initialized, so show and update it.
  90.     m_pMainWnd->ShowWindow(SW_SHOW);
  91.     m_pMainWnd->UpdateWindow();
  92.  
  93.     return TRUE;
  94. }
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CAboutDlg dialog used for App About
  98.  
  99. class CAboutDlg : public CDialog
  100. {
  101. public:
  102.     CAboutDlg();
  103.  
  104. // Dialog Data
  105.     //{{AFX_DATA(CAboutDlg)
  106.     enum { IDD = IDD_ABOUTBOX };
  107.     //}}AFX_DATA
  108.  
  109.     // ClassWizard generated virtual function overrides
  110.     //{{AFX_VIRTUAL(CAboutDlg)
  111.     protected:
  112.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  113.     //}}AFX_VIRTUAL
  114.  
  115. // Implementation
  116. protected:
  117.     //{{AFX_MSG(CAboutDlg)
  118.         // No message handlers
  119.     //}}AFX_MSG
  120.     DECLARE_MESSAGE_MAP()
  121. };
  122.  
  123. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  124. {
  125.     //{{AFX_DATA_INIT(CAboutDlg)
  126.     //}}AFX_DATA_INIT
  127. }
  128.  
  129. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  130. {
  131.     CDialog::DoDataExchange(pDX);
  132.     //{{AFX_DATA_MAP(CAboutDlg)
  133.     //}}AFX_DATA_MAP
  134. }
  135.  
  136. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  137.     //{{AFX_MSG_MAP(CAboutDlg)
  138.         // No message handlers
  139.     //}}AFX_MSG_MAP
  140. END_MESSAGE_MAP()
  141.  
  142. // App command to run the dialog
  143. void CLab3_1App::OnAppAbout()
  144. {
  145.     CAboutDlg aboutDlg;
  146.     aboutDlg.DoModal();
  147. }
  148.  
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CLab3_1App commands
  151.