home *** CD-ROM | disk | FTP | other *** search
/ 3D Graphics Programming for Windows 95 / 3D_Graphics_Programming_for_Windows_95_Microsoft_1996.iso / samples / blobs / stage.cpp < prev    next >
C/C++ Source or Header  |  1996-02-26  |  4KB  |  172 lines

  1. // Stage.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Stage.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CStageApp
  17.  
  18. BEGIN_MESSAGE_MAP(CStageApp, CWinApp)
  19.     //{{AFX_MSG_MAP(CStageApp)
  20.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  21.         // NOTE - the ClassWizard will add and remove mapping macros here.
  22.         //    DO NOT EDIT what you see in these blocks of generated code!
  23.     //}}AFX_MSG_MAP
  24.     // Standard file based document commands
  25.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  26.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  27. END_MESSAGE_MAP()
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CStageApp construction
  31.  
  32. CStageApp::CStageApp()
  33. {
  34.     // TODO: add construction code here,
  35.     // Place all significant initialization in InitInstance
  36. }
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // The one and only CStageApp object
  40.  
  41. CStageApp theApp;
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CStageApp initialization
  45.  
  46. BOOL CStageApp::InitInstance()
  47. {
  48.     // Standard initialization
  49.     // If you are not using these features and wish to reduce the size
  50.     //  of your final executable, you should remove from the following
  51.     //  the specific initialization routines you do not need.
  52.  
  53. #ifdef _AFXDLL
  54.     Enable3dControls();            // Call this when using MFC in a shared DLL
  55. #else
  56.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  57. #endif
  58.  
  59.     // define the name of the registry key where we want to save
  60.     // all our profile information. This value is appended to:
  61.     // HKEY_CURRENT_USER\Software
  62.     // The application name is appended after this key value to
  63.     // form the complete key. For example:
  64.     // HKEY_CURRENT_USER\Software\MyApp
  65.     SetRegistryKey("3dPlus");
  66.  
  67.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  68.  
  69.     // Load the main frame window
  70.     CMainFrame* pFrame = new CMainFrame;
  71.     if (!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | WS_VISIBLE)) {
  72.         return FALSE;
  73.     }
  74.                       
  75.     // save the main window pointer
  76.     m_pMainWnd = pFrame;
  77.  
  78.     return TRUE;
  79. }
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CAboutDlg dialog used for App About
  83.  
  84. class CAboutDlg : public CDialog
  85. {
  86. public:
  87.     CAboutDlg();
  88.  
  89. // Dialog Data
  90.     //{{AFX_DATA(CAboutDlg)
  91.     enum { IDD = IDD_ABOUTBOX };
  92.     //}}AFX_DATA
  93.  
  94.     // ClassWizard generated virtual function overrides
  95.     //{{AFX_VIRTUAL(CAboutDlg)
  96.     protected:
  97.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  98.     //}}AFX_VIRTUAL
  99.  
  100. // Implementation
  101. protected:
  102.     //{{AFX_MSG(CAboutDlg)
  103.         // No message handlers
  104.     //}}AFX_MSG
  105.     DECLARE_MESSAGE_MAP()
  106. };
  107.  
  108. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  109. {
  110.     //{{AFX_DATA_INIT(CAboutDlg)
  111.     //}}AFX_DATA_INIT
  112. }
  113.  
  114. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  115. {
  116.     CDialog::DoDataExchange(pDX);
  117.     //{{AFX_DATA_MAP(CAboutDlg)
  118.     //}}AFX_DATA_MAP
  119. }
  120.  
  121. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  122.     //{{AFX_MSG_MAP(CAboutDlg)
  123.         // No message handlers
  124.     //}}AFX_MSG_MAP
  125. END_MESSAGE_MAP()
  126.  
  127. // App command to run the dialog
  128. void CStageApp::OnAppAbout()
  129. {
  130.     CAboutDlg aboutDlg;
  131.     aboutDlg.DoModal();
  132. }
  133.  
  134. /////////////////////////////////////////////////////////////////////////////
  135. // CStageApp commands
  136.  
  137. BOOL CStageApp::OnIdle(LONG lCount) 
  138. {
  139.     BOOL bMore = CWinApp::OnIdle(lCount);
  140.     
  141.     // get the main frame window
  142.     CMainFrame* pFrame = (CMainFrame*) m_pMainWnd;
  143.     if (pFrame) {
  144.  
  145.         // see if the object controller wants to do anything
  146.         if (pFrame->m_pController) {
  147.             pFrame->m_pController->Update();
  148.         }
  149.  
  150.         // tell the 3D window to update
  151.         if (pFrame->m_wnd3d.Update(1)) {
  152.             bMore = TRUE;
  153.         } 
  154.     }
  155.     return bMore;
  156. }
  157.  
  158. CDocument* CStageApp::OpenDocumentFile(LPCTSTR lpszFileName) 
  159. {
  160.     // we get called here when the user selects an item
  161.     // from the recent file list.
  162.     // The return value is not importenat so long
  163.     // as it's NULL if we fail and non-NULL if we succeed
  164.     
  165.     CMainFrame* pFrame = (CMainFrame*) m_pMainWnd;
  166.     if (pFrame) {
  167.         return (CDocument*) pFrame->OpenFile(lpszFileName);
  168.     } else {
  169.         return NULL;
  170.     }
  171. }
  172.