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

  1. // viewex.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.  
  15. #include "stdafx.h"
  16. #include "viewex.h"
  17.  
  18. #include "splitter.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CViewExApp
  27.  
  28. BEGIN_MESSAGE_MAP(CViewExApp, CWinApp)
  29.     //{{AFX_MSG_MAP(CViewExApp)
  30.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  31.     //}}AFX_MSG_MAP
  32.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  33.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  34.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  35. END_MESSAGE_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CViewExApp construction
  39. // Place all significant initialization in InitInstance
  40.  
  41. CViewExApp::CViewExApp()
  42. {
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // The one and only CViewExApp object
  47.  
  48. CViewExApp NEAR theApp;
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CViewExApp initialization
  52.  
  53. BOOL CViewExApp::InitInstance()
  54. {
  55.     // Standard initialization
  56.     SetDialogBkColor();
  57.  
  58.     // This VIEWEX sample shows several techniques for creating CView
  59.     //  derived classes.   All the views in this sample use the same
  60.     //  CMainDoc class.  For simplicity the CMainDoc class does not
  61.     //  support serialization, but has a very simple data model of
  62.     //  a single string and an RGB color.  We register different
  63.     //  document templates for each of the interesting view types.
  64.  
  65.     // simple text output view
  66.     AddDocTemplate(new CMultiDocTemplate(IDR_TEXTTYPE,
  67.             RUNTIME_CLASS(CMainDoc),
  68.             RUNTIME_CLASS(CMDIChildWnd),
  69.             RUNTIME_CLASS(CTextView)));
  70.  
  71.     // simple color output view
  72.     //   a doc template with no 'fileNewName' so it is not a choice for FileNew
  73.     AddDocTemplate(new CMultiDocTemplate(IDR_COLORTYPE,
  74.             RUNTIME_CLASS(CMainDoc),
  75.             RUNTIME_CLASS(CMDIChildWnd),
  76.             RUNTIME_CLASS(CColorView)));
  77.  
  78.     // form view with input
  79.     AddDocTemplate(new CMultiDocTemplate(IDR_INPUTTYPE,
  80.             RUNTIME_CLASS(CMainDoc),
  81.             RUNTIME_CLASS(CMDIChildWnd),
  82.             RUNTIME_CLASS(CInputView)));
  83.  
  84.     // splitter frame with both simple text output and form input view
  85.     AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT2TYPE,
  86.             RUNTIME_CLASS(CMainDoc),
  87.             RUNTIME_CLASS(CSplitterFrame),
  88.             RUNTIME_CLASS(CTextView)));
  89.  
  90.     // 3-way splitter frame with form input, text output and color output views
  91.     AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT3TYPE,
  92.             RUNTIME_CLASS(CMainDoc),
  93.             RUNTIME_CLASS(C3WaySplitterFrame),
  94.             RUNTIME_CLASS(CInputView)));
  95.  
  96.     // create main MDI Frame window
  97.     // Please note that for simple MDI Frame windows with no toolbar,
  98.     //   status bar or other special behavior, the CMDIFrameWnd class
  99.     //   can be used directly for the main frame window just as the
  100.     //   CMDIChildWnd can be use for a document frame window.
  101.  
  102.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  103.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  104.         return FALSE;
  105.  
  106.     // Also in this example, there is only one menubar shared between
  107.     //  all the views.  The automatic menu enabling support of MFC
  108.     //  will disable the menu items that don't apply based on the
  109.     //  currently active view.  The one MenuBar is used for all
  110.     //  document types, including when there are no open documents.
  111.  
  112.     // Now finally show the main menu
  113.     pMainFrame->ShowWindow(m_nCmdShow);
  114.     pMainFrame->UpdateWindow();
  115.     m_pMainWnd = pMainFrame;
  116.  
  117.     // command line arguments are ignored, create a new (empty) document
  118.     OnFileNew();
  119.  
  120.     return TRUE;
  121. }
  122.  
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CViewExApp commands
  125.  
  126. void CViewExApp::OnAppAbout()
  127. {
  128.     CDialog(IDD_ABOUTBOX).DoModal();
  129. }
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132.