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

  1. // diff.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "diff.h"
  6. #include "progress.h"
  7. #include "splitter.h"
  8. #include "MainFrm.h"
  9. #include "diffDoc.h"
  10. #include "diffView.h"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CDiffApp
  19.  
  20. BEGIN_MESSAGE_MAP(CDiffApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CDiffApp)
  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. // CDiffApp construction
  35.  
  36. CDiffApp::CDiffApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CDiffApp object
  44.  
  45. CDiffApp theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDiffApp initialization
  49.  
  50. BOOL CDiffApp::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.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  66.  
  67.     // Register the application's document templates.  Document templates
  68.     //  serve as the connection between documents, frame windows and views.
  69.  
  70.     CSingleDocTemplate* pDocTemplate;
  71.     pDocTemplate = new CSingleDocTemplate(
  72.         IDR_MAINFRAME,
  73.         RUNTIME_CLASS(CDiffDoc),
  74.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  75.         RUNTIME_CLASS(CDiffView));
  76.     AddDocTemplate(pDocTemplate);
  77.  
  78.     // Enable DDE Execute open
  79.     EnableShellOpen();
  80.     RegisterShellFileTypes();
  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.     // Enable drag/drop open
  91.     m_pMainWnd->DragAcceptFiles();
  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. // Implementation
  110. protected:
  111.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  112.     //{{AFX_MSG(CAboutDlg)
  113.         // No message handlers
  114.     //}}AFX_MSG
  115.     DECLARE_MESSAGE_MAP()
  116. };
  117.  
  118. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  119. {
  120.     //{{AFX_DATA_INIT(CAboutDlg)
  121.     //}}AFX_DATA_INIT
  122. }
  123.  
  124. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  125. {
  126.     CDialog::DoDataExchange(pDX);
  127.     //{{AFX_DATA_MAP(CAboutDlg)
  128.     //}}AFX_DATA_MAP
  129. }
  130.  
  131. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  132.     //{{AFX_MSG_MAP(CAboutDlg)
  133.         // No message handlers
  134.     //}}AFX_MSG_MAP
  135. END_MESSAGE_MAP()
  136.  
  137. // App command to run the dialog
  138. void CDiffApp::OnAppAbout()
  139. {
  140.     CAboutDlg aboutDlg;
  141.     aboutDlg.DoModal();
  142. }
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CDiffApp commands
  146.