home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch19 / pad / pad.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-25  |  3.7 KB  |  149 lines

  1. // pad.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "pad.h"
  6.  
  7. //////////////////////
  8. // MY CODE STARTS HERE
  9. //////////////////////
  10.  
  11. #include "mysplit.h"
  12.  
  13. ////////////////////
  14. // MY CODE ENDS HERE
  15. ////////////////////
  16.  
  17. #include "mainfrm.h"
  18. #include "paddoc.h"
  19. #include "padview.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CPadApp
  28.  
  29. BEGIN_MESSAGE_MAP(CPadApp, CWinApp)
  30.     //{{AFX_MSG_MAP(CPadApp)
  31.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  32.         // NOTE - the ClassWizard will add and remove mapping macros here.
  33.         //    DO NOT EDIT what you see in these blocks of generated code!
  34.     //}}AFX_MSG_MAP
  35.     // Standard file based document commands
  36.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  37.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CPadApp construction
  42.  
  43. CPadApp::CPadApp()
  44. {
  45.     // TODO: add construction code here,
  46.     // Place all significant initialization in InitInstance
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // The one and only CPadApp object
  51.  
  52. CPadApp NEAR theApp;
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CPadApp initialization
  56.  
  57. BOOL CPadApp::InitInstance()
  58. {
  59.     // Standard initialization
  60.     // If you are not using these features and wish to reduce the size
  61.     //  of your final executable, you should remove from the following
  62.     //  the specific initialization routines you do not need.
  63.  
  64.     SetDialogBkColor();        // Set dialog background color to gray
  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.     CMultiDocTemplate* pDocTemplate;
  71.     pDocTemplate = new CMultiDocTemplate(
  72.         IDR_PADTYPE,
  73.         RUNTIME_CLASS(CPadDoc),
  74.         RUNTIME_CLASS(CMySplit),     // the splitter class.
  75.         RUNTIME_CLASS(CPadView));
  76.     AddDocTemplate(pDocTemplate);
  77.  
  78.     // create main MDI Frame window
  79.     CMainFrame* pMainFrame = new CMainFrame;
  80.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  81.         return FALSE;
  82.     m_pMainWnd = pMainFrame;
  83.  
  84.     // create a new (empty) document
  85.     OnFileNew();
  86.  
  87.     if (m_lpCmdLine[0] != '\0')
  88.     {
  89.         // TODO: add command line processing here
  90.     }
  91.  
  92.     // The main window has been initialized, so show and update it.
  93.     pMainFrame->ShowWindow(m_nCmdShow);
  94.     pMainFrame->UpdateWindow();
  95.  
  96.     return TRUE;
  97. }
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CAboutDlg dialog used for App About
  101.  
  102. class CAboutDlg : public CDialog
  103. {
  104. public:
  105.     CAboutDlg();
  106.  
  107. // Dialog Data
  108.     //{{AFX_DATA(CAboutDlg)
  109.     enum { IDD = IDD_ABOUTBOX };
  110.     //}}AFX_DATA
  111.  
  112. // Implementation
  113. protected:
  114.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  115.     //{{AFX_MSG(CAboutDlg)
  116.         // No message handlers
  117.     //}}AFX_MSG
  118.     DECLARE_MESSAGE_MAP()
  119. };
  120.  
  121. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  122. {
  123.     //{{AFX_DATA_INIT(CAboutDlg)
  124.     //}}AFX_DATA_INIT
  125. }
  126.  
  127. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  128. {
  129.     CDialog::DoDataExchange(pDX);
  130.     //{{AFX_DATA_MAP(CAboutDlg)
  131.     //}}AFX_DATA_MAP
  132. }
  133.  
  134. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  135.     //{{AFX_MSG_MAP(CAboutDlg)
  136.         // No message handlers
  137.     //}}AFX_MSG_MAP
  138. END_MESSAGE_MAP()
  139.  
  140. // App command to run the dialog
  141. void CPadApp::OnAppAbout()
  142. {
  143.     CAboutDlg aboutDlg;
  144.     aboutDlg.DoModal();
  145. }
  146.  
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CPadApp commands
  149.