home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / atltangram / mfctangram / mfctangram.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  137 lines

  1. // MFCTangram.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #include "stdafx.h"
  14. #include "MFCTangram.h"
  15.  
  16. #include "MainFrm.h"
  17.  
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CMFCTangramApp
  26.  
  27. BEGIN_MESSAGE_MAP(CMFCTangramApp, CWinApp)
  28.     //{{AFX_MSG_MAP(CMFCTangramApp)
  29.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  30.         // NOTE - the ClassWizard will add and remove mapping macros here.
  31.         //    DO NOT EDIT what you see in these blocks of generated code!
  32.     //}}AFX_MSG_MAP
  33.     // Standard file based document commands
  34.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  35.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  36.     // Standard print setup command
  37.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CMFCTangramApp construction
  42.  
  43. CMFCTangramApp::CMFCTangramApp()
  44. {
  45.     // TODO: add construction code here,
  46.     // Place all significant initialization in InitInstance
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // The one and only CMFCTangramApp object
  51.  
  52. CMFCTangramApp theApp;
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CMFCTangramApp initialization
  56.  
  57. BOOL CMFCTangramApp::InitInstance()
  58. {
  59.  
  60.     // Initialize the COM Library.
  61.     ::CoInitialize(NULL) ;
  62.  
  63.     // Create the main window.
  64.     CMFCMainFrame* pMainWnd = new CMFCMainFrame ;
  65.     ASSERT(pMainWnd) ;
  66.  
  67.     // Create the main window.
  68.     if (pMainWnd->Create())
  69.     {
  70.         m_pMainWnd = pMainWnd ;
  71.         return TRUE ;
  72.     }
  73.     else
  74.     {
  75.         TRACE0("CMFCTangramApp::InitInstance CMainWnd::Create Failed.\r\n") ;
  76.         // We do not need to delete pMainWnd. PostNcDestory does it for us.
  77.         //delete pMainWnd ;
  78.         return FALSE ;
  79.     }
  80. }
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CAboutDlg dialog used for App About
  84.  
  85. class CAboutDlg : public CDialog
  86. {
  87. public:
  88.     CAboutDlg();
  89.  
  90. // Dialog Data
  91.     //{{AFX_DATA(CAboutDlg)
  92.     enum { IDD = IDD_ABOUTBOX };
  93.     //}}AFX_DATA
  94.  
  95.     // ClassWizard generated virtual function overrides
  96.     //{{AFX_VIRTUAL(CAboutDlg)
  97.     protected:
  98.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  99.     //}}AFX_VIRTUAL
  100.  
  101. // Implementation
  102. protected:
  103.     //{{AFX_MSG(CAboutDlg)
  104.         // No message handlers
  105.     //}}AFX_MSG
  106.     DECLARE_MESSAGE_MAP()
  107. };
  108.  
  109. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  110. {
  111.     //{{AFX_DATA_INIT(CAboutDlg)
  112.     //}}AFX_DATA_INIT
  113. }
  114.  
  115. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  116. {
  117.     CDialog::DoDataExchange(pDX);
  118.     //{{AFX_DATA_MAP(CAboutDlg)
  119.     //}}AFX_DATA_MAP
  120. }
  121.  
  122. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  123.     //{{AFX_MSG_MAP(CAboutDlg)
  124.         // No message handlers
  125.     //}}AFX_MSG_MAP
  126. END_MESSAGE_MAP()
  127.  
  128. // App command to run the dialog
  129. void CMFCTangramApp::OnAppAbout()
  130. {
  131.     CAboutDlg aboutDlg;
  132.     aboutDlg.DoModal();
  133. }
  134.  
  135. /////////////////////////////////////////////////////////////////////////////
  136. // CMFCTangramApp commands
  137.