home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c06 / lab05 / ex03 / diff.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  4.0 KB  |  157 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 "diffDoc.h"
  9. #include "diffView.h"
  10. #include "FindDiff.h"
  11. #include "MainFrm.h"
  12.  
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CDiffApp
  20.  
  21. BEGIN_MESSAGE_MAP(CDiffApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CDiffApp)
  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. // CDiffApp construction
  36.  
  37. CDiffApp::CDiffApp()
  38. {
  39.  
  40.  
  41.     // TODO: add construction code here,
  42.     // Place all significant initialization in InitInstance
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // The one and only CDiffApp object
  47.  
  48. CDiffApp theApp;
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CDiffApp initialization
  52.  
  53. BOOL CDiffApp::InitInstance()
  54. {
  55.     //setup to read/write to the Registry rather than an .ini
  56.     CString Key;
  57.     Key.LoadString(AFX_IDS_APP_TITLE);
  58.     SetRegistryKey (Key);
  59.  
  60.     AfxEnableControlContainer();
  61.  
  62.     // Standard initialization
  63.     // If you are not using these features and wish to reduce the size
  64.     //  of your final executable, you should remove from the following
  65.     //  the specific initialization routines you do not need.
  66.  
  67. #ifdef _AFXDLL
  68.     Enable3dControls();            // Call this when using MFC in a shared DLL
  69. #else
  70.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  71. #endif
  72.  
  73.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  74.  
  75.     // Register the application's document templates.  Document templates
  76.     //  serve as the connection between documents, frame windows and views.
  77.  
  78.     CSingleDocTemplate* pDocTemplate;
  79.     pDocTemplate = new CSingleDocTemplate(
  80.         IDR_MAINFRAME,
  81.         RUNTIME_CLASS(CDiffDoc),
  82.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  83.         RUNTIME_CLASS(CDiffView));
  84.     AddDocTemplate(pDocTemplate);
  85.  
  86.     // Enable DDE Execute open
  87.     EnableShellOpen();
  88.     RegisterShellFileTypes();
  89.  
  90.     // Parse command line for standard shell commands, DDE, file open
  91.     CCommandLineInfo cmdInfo;
  92.     ParseCommandLine(cmdInfo);
  93.  
  94.     // Dispatch commands specified on the command line
  95.     if (!ProcessShellCommand(cmdInfo))
  96.         return FALSE;
  97.  
  98.     // Enable drag/drop open
  99.     m_pMainWnd->DragAcceptFiles();
  100.     
  101.     // Get registry data
  102.     GetMainFrame()->ReadRegistryPreferences();
  103.  
  104.     return TRUE;
  105. }
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CAboutDlg dialog used for App About
  109.  
  110. class CAboutDlg : public CDialog
  111. {
  112. public:
  113.     CAboutDlg();
  114.  
  115. // Dialog Data
  116.     //{{AFX_DATA(CAboutDlg)
  117.     enum { IDD = IDD_ABOUTBOX };
  118.     //}}AFX_DATA
  119.  
  120. // Implementation
  121. protected:
  122.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  123.     //{{AFX_MSG(CAboutDlg)
  124.         // No message handlers
  125.     //}}AFX_MSG
  126.     DECLARE_MESSAGE_MAP()
  127. };
  128.  
  129. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  130. {
  131.     //{{AFX_DATA_INIT(CAboutDlg)
  132.     //}}AFX_DATA_INIT
  133. }
  134.  
  135. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  136. {
  137.     CDialog::DoDataExchange(pDX);
  138.     //{{AFX_DATA_MAP(CAboutDlg)
  139.     //}}AFX_DATA_MAP
  140. }
  141.  
  142. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  143.     //{{AFX_MSG_MAP(CAboutDlg)
  144.         // No message handlers
  145.     //}}AFX_MSG_MAP
  146. END_MESSAGE_MAP()
  147.  
  148. // App command to run the dialog
  149. void CDiffApp::OnAppAbout()
  150. {
  151.     CAboutDlg aboutDlg;
  152.     aboutDlg.DoModal();
  153. }
  154.  
  155. /////////////////////////////////////////////////////////////////////////////
  156. // CDiffApp commands
  157.