home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c08 / dynalist / dynalist.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.9 KB  |  151 lines

  1. // DynaList.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DynaList.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "ChildFrm.h"
  9. #include "DLDoc.h"
  10. #include "DLView.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CDynaListApp
  20.  
  21. BEGIN_MESSAGE_MAP(CDynaListApp, CWinApp)
  22.     //{{AFX_MSG_MAP(CDynaListApp)
  23.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  24.         // NOTE - the ClassWizard will add and remove mapping macros here.
  25.         //    DO NOT EDIT what you see in these blocks of generated code!
  26.     //}}AFX_MSG_MAP
  27.     // Standard file based document commands
  28.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  29.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDynaListApp construction
  34.  
  35. CDynaListApp::CDynaListApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CDynaListApp object
  43.  
  44. CDynaListApp theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CDynaListApp initialization
  48.  
  49. BOOL CDynaListApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.     // If you are not using these features and wish to reduce the size
  53.     //  of your final executable, you should remove from the following
  54.     //  the specific initialization routines you do not need.
  55.  
  56. #ifdef _AFXDLL
  57.     Enable3dControls();            // Call this when using MFC in a shared DLL
  58. #else
  59.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  60. #endif
  61.  
  62.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  63.  
  64.     // Register the application's document templates.  Document templates
  65.     //  serve as the connection between documents, frame windows and views.
  66.  
  67.     CMultiDocTemplate* pDocTemplate;
  68.     pDocTemplate = new CMultiDocTemplate(
  69.         IDR_DYNALITYPE,
  70.         RUNTIME_CLASS(CDynaListDoc),
  71.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  72.         RUNTIME_CLASS(CDynaListView));
  73.     AddDocTemplate(pDocTemplate);
  74.  
  75.     // create main MDI Frame window
  76.     CMainFrame* pMainFrame = new CMainFrame;
  77.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  78.         return FALSE;
  79.     m_pMainWnd = pMainFrame;
  80.  
  81.     // Parse command line for standard shell commands, DDE, file open
  82.     CCommandLineInfo cmdInfo;
  83.     ParseCommandLine(cmdInfo);
  84.  
  85.     // Dispatch commands specified on the command line
  86.     if (!ProcessShellCommand(cmdInfo))
  87.         return FALSE;
  88.  
  89.     // The main window has been initialized, so show and update it.
  90.     pMainFrame->ShowWindow(m_nCmdShow);
  91.     pMainFrame->UpdateWindow();
  92.  
  93.     return TRUE;
  94. }
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CAboutDlg dialog used for App About
  98.  
  99. class CAboutDlg : public CDialog
  100. {
  101. public:
  102.     CAboutDlg();
  103.  
  104. // Dialog Data
  105.     //{{AFX_DATA(CAboutDlg)
  106.     enum { IDD = IDD_ABOUTBOX };
  107.     //}}AFX_DATA
  108.  
  109.     // ClassWizard generated virtual function overrides
  110.     //{{AFX_VIRTUAL(CAboutDlg)
  111.     protected:
  112.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  113.     //}}AFX_VIRTUAL
  114.  
  115. // Implementation
  116. protected:
  117.     //{{AFX_MSG(CAboutDlg)
  118.         // No message handlers
  119.     //}}AFX_MSG
  120.     DECLARE_MESSAGE_MAP()
  121. };
  122.  
  123. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  124. {
  125.     //{{AFX_DATA_INIT(CAboutDlg)
  126.     //}}AFX_DATA_INIT
  127. }
  128.  
  129. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  130. {
  131.     CDialog::DoDataExchange(pDX);
  132.     //{{AFX_DATA_MAP(CAboutDlg)
  133.     //}}AFX_DATA_MAP
  134. }
  135.  
  136. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  137.     //{{AFX_MSG_MAP(CAboutDlg)
  138.         // No message handlers
  139.     //}}AFX_MSG_MAP
  140. END_MESSAGE_MAP()
  141.  
  142. // App command to run the dialog
  143. void CDynaListApp::OnAppAbout()
  144. {
  145.     CAboutDlg aboutDlg;
  146.     aboutDlg.DoModal();
  147. }
  148.  
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CDynaListApp commands
  151.