home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c11 / lab02 / baseline / ic_2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  4.1 KB  |  154 lines

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