home *** CD-ROM | disk | FTP | other *** search
/ Using VRML (Special Edition) / Special_Edition_Using_VRML_CDROM_Que_1996.iso / webpages / software / win95 / browsers / ambersw / tutorial / lesson3 / lesson3.cpp < prev    next >
C/C++ Source or Header  |  1995-09-17  |  4KB  |  164 lines

  1. // lesson3.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "lesson3.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "lessodoc.h"
  9. #include "lessovw.h"
  10. #include "amber.hpp"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // Clesson3App
  19.  
  20. BEGIN_MESSAGE_MAP(Clesson3App, CWinApp)
  21.     //{{AFX_MSG_MAP(Clesson3App)
  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.     // Standard print setup command
  30.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Clesson3App construction
  35.  
  36. Clesson3App::Clesson3App()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only Clesson3App object
  44.  
  45. Clesson3App theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // Clesson3App initialization
  49. universeClass *univ;
  50. BOOL Clesson3App::InitInstance()
  51. {
  52.     // Standard initialization
  53.     // If you are not using these features and wish to reduce the size
  54.     //  of your final executable, you should remove from the following
  55.     //  the specific initialization routines you do not need.
  56.  
  57.     Enable3dControls();
  58.  
  59.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  60.  
  61.  
  62.     // Amber instance initialiation
  63.     //
  64.     amber = new amberClass();
  65.     
  66.     // Main universe
  67.     //
  68.     univ = new universeClass();
  69.  
  70.     // Register the application's document templates.  Document templates
  71.     //  serve as the connection between documents, frame windows and views.
  72.  
  73.     CSingleDocTemplate* pDocTemplate;
  74.     pDocTemplate = new CSingleDocTemplate(
  75.         IDR_MAINFRAME,
  76.         RUNTIME_CLASS(Clesson3Doc),
  77.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  78.         RUNTIME_CLASS(Clesson3View));
  79.     AddDocTemplate(pDocTemplate);
  80.  
  81.     // Enable DDE Execute open
  82.     EnableShellOpen();
  83.     RegisterShellFileTypes();
  84.  
  85.     // simple command line parsing
  86.     if (m_lpCmdLine[0] == '\0')
  87.     {
  88.         // create a new (empty) document
  89.         OnFileNew();
  90.     }
  91.     else
  92.     {
  93.         // open an existing document
  94.         OpenDocumentFile(m_lpCmdLine);
  95.     }
  96.  
  97.     // Enable drag/drop open
  98.     m_pMainWnd->DragAcceptFiles();
  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. // Implementation
  117. protected:
  118.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  119.     //{{AFX_MSG(CAboutDlg)
  120.         // No message handlers
  121.     //}}AFX_MSG
  122.     DECLARE_MESSAGE_MAP()
  123. };
  124.  
  125. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  126. {
  127.     //{{AFX_DATA_INIT(CAboutDlg)
  128.     //}}AFX_DATA_INIT
  129. }
  130.  
  131. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  132. {
  133.     CDialog::DoDataExchange(pDX);
  134.     //{{AFX_DATA_MAP(CAboutDlg)
  135.     //}}AFX_DATA_MAP
  136. }
  137.  
  138. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  139.     //{{AFX_MSG_MAP(CAboutDlg)
  140.         // No message handlers
  141.     //}}AFX_MSG_MAP
  142. END_MESSAGE_MAP()
  143.  
  144. // App command to run the dialog
  145. void Clesson3App::OnAppAbout()
  146. {
  147.     CAboutDlg aboutDlg;
  148.     aboutDlg.DoModal();
  149. }
  150.  
  151. /////////////////////////////////////////////////////////////////////////////
  152. // Clesson3App commands
  153.  
  154. int Clesson3App::ExitInstance() 
  155. {
  156.     // TODO: Add your specialized code here and/or call the base class
  157.  
  158.     // Delete Amber instance
  159.     //    
  160.     delete amber;
  161.  
  162.     return CWinApp::ExitInstance();
  163. }
  164.