home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual C++ 4 (2nd Edition) / VisualC4.ISO / miniedt1 / miniedit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  3.7 KB  |  140 lines

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