home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual C++ 4 (2nd Edition) / VisualC4.ISO / miniedt3 / miniedit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  4.2 KB  |  158 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 "ChildFrm.h"
  9. #include "MiniEDoc.h"
  10. #include "MiniEdVw.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. // CMiniEditApp
  20.  
  21. BEGIN_MESSAGE_MAP(CMiniEditApp, CWinApp)
  22.    //{{AFX_MSG_MAP(CMiniEditApp)
  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. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CMiniEditApp construction
  34.  
  35. CMiniEditApp::CMiniEditApp()
  36. {
  37.    // TODO: add construction code here,
  38.    // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CMiniEditApp object
  43.  
  44. CMiniEditApp theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMiniEditApp initialization
  48.  
  49. BOOL CMiniEditApp::InitInstance()
  50. {
  51.    // Standard initialization
  52.    // If you are not using these features and wish to reduce the size
  53.    //  of your final executable, you should remove from the following
  54.    //  the specific initialization routines you do not need.
  55.  
  56. #ifdef _AFXDLL
  57.    Enable3dControls();        // Call this when using MFC in a shared DLL
  58. #else
  59.    Enable3dControlsStatic();  // Call this when linking to MFC statically
  60. #endif
  61.  
  62.    LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  63.  
  64.    // Register the application's document templates.  Document templates
  65.    //  serve as the connection between documents, frame windows and views.
  66.  
  67.    CMultiDocTemplate* pDocTemplate;
  68.    pDocTemplate = new CMultiDocTemplate(
  69.       IDR_TEXTTYPE,
  70.       RUNTIME_CLASS(CMiniEditDoc),
  71.       RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  72.       RUNTIME_CLASS(CMiniEditView));
  73.    AddDocTemplate(pDocTemplate);
  74.  
  75.    // create main MDI Frame window
  76.    CMainFrame* pMainFrame = new CMainFrame;
  77.    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  78.       return FALSE;
  79.    m_pMainWnd = pMainFrame;
  80.  
  81.    // Enable drag/drop open
  82.    m_pMainWnd->DragAcceptFiles();
  83.  
  84.    // Enable DDE Execute open
  85.    EnableShellOpen();
  86.    RegisterShellFileTypes(TRUE);
  87.  
  88.    // Parse command line for standard shell commands, DDE, file open
  89.    CCommandLineInfo cmdInfo;
  90.    ParseCommandLine(cmdInfo);
  91.  
  92.    // Dispatch commands specified on the command line
  93.    if (!ProcessShellCommand(cmdInfo))
  94.       return FALSE;
  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 CMiniEditApp::OnAppAbout()
  151. {
  152.    CAboutDlg aboutDlg;
  153.    aboutDlg.DoModal();
  154. }
  155.  
  156. /////////////////////////////////////////////////////////////////////////////
  157. // CMiniEditApp commands
  158.