home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / sdi2views / sdi2views.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.9 KB  |  154 lines

  1. // SDI2Views.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "SDI2Views.h"
  6.  
  7. #include "SDI2ViewsDoc.h"
  8. #include "DefaultView.h"
  9. #include "ItalicsView.h"
  10.  
  11. #include "MainFrm.h"
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CSDI2ViewsApp
  21.  
  22. BEGIN_MESSAGE_MAP(CSDI2ViewsApp, CWinApp)
  23.     //{{AFX_MSG_MAP(CSDI2ViewsApp)
  24.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  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. // CSDI2ViewsApp construction
  35.  
  36. CSDI2ViewsApp::CSDI2ViewsApp()
  37. {
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CSDI2ViewsApp object
  42.  
  43. CSDI2ViewsApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CSDI2ViewsApp initialization
  47.  
  48. BOOL CSDI2ViewsApp::InitInstance()
  49. {
  50.     AfxEnableControlContainer();
  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.  
  75.     pDocTemplate = new CSingleDocTemplate(
  76.         IDR_MAINFRAME,
  77.         RUNTIME_CLASS(CSDI2ViewsDoc),
  78.         RUNTIME_CLASS(CMainFrame),
  79.         RUNTIME_CLASS(CDefaultView));
  80.     AddDocTemplate(pDocTemplate);
  81.  
  82.     // Parse command line for standard shell commands, DDE, file open
  83.     CCommandLineInfo cmdInfo;
  84.     ParseCommandLine(cmdInfo);
  85.  
  86.     // Dispatch commands specified on the command line
  87.     if (!ProcessShellCommand(cmdInfo))
  88.         return FALSE;
  89.  
  90.     // The one and only window has been initialized, so show and update it.
  91.     m_nCmdShow = SW_SHOW;
  92.     m_pMainWnd->ShowWindow(m_nCmdShow);
  93.     m_pMainWnd->UpdateWindow();
  94.  
  95.     return TRUE;
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CSDI2ViewsApp commands
  100.  
  101.  
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CAboutDlg dialog used for App About
  104. class CAboutDlg : public CDialog
  105. {
  106. public:
  107.     CAboutDlg();
  108.  
  109. // Dialog Data
  110.     //{{AFX_DATA(CAboutDlg)
  111.     enum { IDD = IDD_ABOUTBOX };
  112.     //}}AFX_DATA
  113.  
  114.     // ClassWizard generated virtual function overrides
  115.     //{{AFX_VIRTUAL(CAboutDlg)
  116.     protected:
  117.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  118.     //}}AFX_VIRTUAL
  119.  
  120. // Implementation
  121. protected:
  122.     //{{AFX_MSG(CAboutDlg)
  123.         // No message handlers
  124.     //}}AFX_MSG
  125.     DECLARE_MESSAGE_MAP()
  126. };
  127.  
  128. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  129. {
  130.     //{{AFX_DATA_INIT(CAboutDlg)
  131.     //}}AFX_DATA_INIT
  132. }
  133.  
  134. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  135. {
  136.     CDialog::DoDataExchange(pDX);
  137.     //{{AFX_DATA_MAP(CAboutDlg)
  138.     //}}AFX_DATA_MAP
  139. }
  140.  
  141. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  142.     //{{AFX_MSG_MAP(CAboutDlg)
  143.         // No message handlers
  144.     //}}AFX_MSG_MAP
  145. END_MESSAGE_MAP()
  146.  
  147. // App command to run the dialog
  148. void CSDI2ViewsApp::OnAppAbout()
  149. {
  150.     CAboutDlg aboutDlg;
  151.     aboutDlg.DoModal();
  152. }
  153.  
  154.