home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c05 / lab07 / ex02 / diff.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.7 KB  |  148 lines

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