home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / SCRIBBLE / STEP2 / SCRIBBLE.CP_ / SCRIBBLE.CP
Encoding:
Text File  |  1993-02-08  |  4.4 KB  |  161 lines

  1. // scribble.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. #include "stdafx.h"
  15. #include "scribble.h"
  16.  
  17. #include "mainfrm.h"
  18. #include "scribdoc.h"
  19. #include "scribvw.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CScribbleApp
  28.  
  29. BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp)
  30.     //{{AFX_MSG_MAP(CScribbleApp)
  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.     // Standard print setup command
  39.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CScribbleApp construction
  44.  
  45. CScribbleApp::CScribbleApp()
  46. {
  47.     // TODO: add construction code here,
  48.     // Place all significant initialization in InitInstance
  49. }
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // The one and only CScribbleApp object
  53.  
  54. CScribbleApp NEAR theApp;
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CScribbleApp initialization
  58.  
  59. BOOL CScribbleApp::InitInstance()
  60. {
  61.     // Standard initialization
  62.     // If you are not using these features and wish to reduce the size
  63.     //  of your final executable, you should remove from the following
  64.     //  the specific initialization routines you do not need.
  65.  
  66.     SetDialogBkColor();        // set dialog background color to gray
  67.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  68.  
  69.     // Register the application's document templates.  Document templates
  70.     //  serve as the connection between documents, frame windows and views.
  71.  
  72.     AddDocTemplate(new CMultiDocTemplate(IDR_SCRIBTYPE,
  73.             RUNTIME_CLASS(CScribDoc),
  74.             RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  75.             RUNTIME_CLASS(CScribView)));
  76.  
  77.     // create main MDI Frame window
  78.     CMainFrame* pMainFrame = new CMainFrame;
  79.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  80.         return FALSE;
  81.     pMainFrame->ShowWindow(m_nCmdShow);
  82.     pMainFrame->UpdateWindow();
  83.     m_pMainWnd = pMainFrame;
  84.  
  85.     // enable file manager drag/drop and DDE Execute open
  86.     m_pMainWnd->DragAcceptFiles();
  87.     EnableShellOpen();
  88.     RegisterShellFileTypes();
  89.  
  90.     // simple command line parsing
  91.     if (m_lpCmdLine[0] == '\0')
  92.     {
  93.         // create a new (empty) document
  94.         OnFileNew();
  95.     }
  96.     else if ((m_lpCmdLine[0] == '-' || m_lpCmdLine[0] == '/') &&
  97.         (m_lpCmdLine[1] == 'e' || m_lpCmdLine[1] == 'E'))
  98.     {
  99.         // program launched embedded - wait for DDE or OLE open
  100.     }
  101.     else
  102.     {
  103.         // open an existing document
  104.         OpenDocumentFile(m_lpCmdLine);
  105.     }
  106.  
  107.  
  108.     return TRUE;
  109. }
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CAboutDlg dialog used for App About
  113.  
  114. class CAboutDlg : public CDialog
  115. {
  116. public:
  117.     CAboutDlg();
  118.  
  119. // Dialog Data
  120.     //{{AFX_DATA(CAboutDlg)
  121.     enum { IDD = IDD_ABOUTBOX };
  122.     //}}AFX_DATA
  123.  
  124. // Implementation
  125. protected:
  126.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  127.     //{{AFX_MSG(CAboutDlg)
  128.         // No message handlers
  129.     //}}AFX_MSG
  130.     DECLARE_MESSAGE_MAP()
  131. };
  132.  
  133. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  134. {
  135.     //{{AFX_DATA_INIT(CAboutDlg)
  136.     //}}AFX_DATA_INIT
  137. }
  138.  
  139. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  140. {
  141.     CDialog::DoDataExchange(pDX);
  142.     //{{AFX_DATA_MAP(CAboutDlg)
  143.     //}}AFX_DATA_MAP
  144. }
  145.  
  146. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  147.     //{{AFX_MSG_MAP(CAboutDlg)
  148.         // No message handlers
  149.     //}}AFX_MSG_MAP
  150. END_MESSAGE_MAP()
  151.  
  152. // App command to run the dialog
  153. void CScribbleApp::OnAppAbout()
  154. {
  155.     CAboutDlg aboutDlg;
  156.     aboutDlg.DoModal();
  157. }
  158.  
  159. /////////////////////////////////////////////////////////////////////////////
  160. // CScribbleApp commands
  161.