home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch05 / fileview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-30  |  4.1 KB  |  158 lines

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