home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / treelist / tree.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.5 KB  |  137 lines

  1. // tree.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tree.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #include "AnmlData.h"
  10.  
  11. #include "treeDoc.h"
  12. #include "TreeView.h"
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CTreeApp
  22.  
  23. BEGIN_MESSAGE_MAP(CTreeApp, CWinApp)
  24.     //{{AFX_MSG_MAP(CTreeApp)
  25.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  26.         // NOTE - the ClassWizard will add and remove mapping macros here.
  27.         //    DO NOT EDIT what you see in these blocks of generated code!
  28.     //}}AFX_MSG_MAP
  29.     // Standard file based document commands
  30.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  31.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CTreeApp construction
  36. // Implemented inline
  37. /////////////////////////////////////////////////////////////////////////////
  38. // The one and only CTreeApp object
  39.  
  40. CTreeApp theApp;
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CTreeApp initialization
  44.  
  45. BOOL CTreeApp::InitInstance()
  46. {
  47.     // Standard initialization
  48.     // If you are not using these features and wish to reduce the size
  49.     //  of your final executable, you should remove from the following
  50.     //  the specific initialization routines you do not need.
  51.  
  52. #ifdef _AFXDLL
  53.     Enable3dControls();            // Call this when using MFC in a shared DLL
  54. #else
  55.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  56. #endif
  57.  
  58.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  59.  
  60.     // Register the application's document templates.  Document templates
  61.     //  serve as the connection between documents, frame windows and views.
  62.  
  63.     CSingleDocTemplate* pDocTemplate;
  64.     pDocTemplate = new CSingleDocTemplate(
  65.         IDR_MAINFRAME,
  66.         RUNTIME_CLASS(CTreeDoc),
  67.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  68.         RUNTIME_CLASS(CSimpleTreeView));
  69.     AddDocTemplate(pDocTemplate);
  70.  
  71.     // Parse command line for standard shell commands, DDE, file open
  72.     CCommandLineInfo cmdInfo;
  73.     ParseCommandLine(cmdInfo);
  74.  
  75.     // Dispatch commands specified on the command line
  76.     if (!ProcessShellCommand(cmdInfo))
  77.         return FALSE;
  78.  
  79.     return TRUE;
  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 CTreeApp::OnAppAbout()
  130. {
  131.     CAboutDlg aboutDlg;
  132.     aboutDlg.DoModal();
  133. }
  134.  
  135. /////////////////////////////////////////////////////////////////////////////
  136. // CTreeApp commands
  137.