Demo.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // Demo.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "Demo.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "ChildSplitFrame.h"
  8. #include "ChildMixedFrame.h"
  9. #include "DemoDoc.h"
  10. #include "DemoView.h"
  11. #include "PropertyFormView.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CDemoApp
  19. BEGIN_MESSAGE_MAP(CDemoApp, CWinApp)
  20. //{{AFX_MSG_MAP(CDemoApp)
  21. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22. //}}AFX_MSG_MAP
  23. // Standard file based document commands
  24. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  25. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CDemoApp construction
  29. CDemoApp::CDemoApp()
  30. {
  31. }
  32. /////////////////////////////////////////////////////////////////////////////
  33. // The one and only CDemoApp object
  34. CDemoApp theApp;
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CDemoApp initialization
  37. BOOL CDemoApp::InitInstance()
  38. {
  39. // Standard initialization
  40. // Change the registry key under which our settings are stored.
  41. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  42. LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
  43. // Register document templates
  44. CMultiDocTemplate* pDocTemplate;
  45. pDocTemplate = new CMultiDocTemplate(
  46. IDR_DEMOTYPE,
  47. RUNTIME_CLASS(CDemoDoc),
  48. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  49. RUNTIME_CLASS(CDemoView));
  50. AddDocTemplate(pDocTemplate);
  51. pDocTemplate = new CMultiDocTemplate(
  52. IDR_DEMOTYPE1,
  53. RUNTIME_CLASS(CDemoDoc),
  54. RUNTIME_CLASS(CChildSplitFrame), // custom MDI child frame
  55. RUNTIME_CLASS(CDemoView));
  56. AddDocTemplate(pDocTemplate);
  57. pDocTemplate = new CMultiDocTemplate(
  58. IDR_DEMOTYPE2,
  59. RUNTIME_CLASS(CDemoDoc),
  60. RUNTIME_CLASS(CChildMixedFrame), // custom MDI child frame
  61. RUNTIME_CLASS(CPropertyFormView));
  62. AddDocTemplate(pDocTemplate);
  63. // create main MDI Frame window
  64. CMainFrame* pMainFrame = new CMainFrame;
  65. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  66. return FALSE;
  67. m_pMainWnd = pMainFrame;
  68. // Parse command line for standard shell commands, DDE, file open
  69. CCommandLineInfo cmdInfo;
  70. ParseCommandLine(cmdInfo);
  71. // Dispatch commands specified on the command line
  72. if (!ProcessShellCommand(cmdInfo))
  73. return FALSE;
  74. pMainFrame->ShowWindow(m_nCmdShow);
  75. pMainFrame->UpdateWindow();
  76. return TRUE;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CAboutDlg dialog used for App About
  80. class CAboutDlg : public CDialog
  81. {
  82. public:
  83. CAboutDlg();
  84. // Dialog Data
  85. //{{AFX_DATA(CAboutDlg)
  86. enum { IDD = IDD_ABOUTBOX };
  87. //}}AFX_DATA
  88. // ClassWizard generated virtual function overrides
  89. //{{AFX_VIRTUAL(CAboutDlg)
  90. protected:
  91. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  92. //}}AFX_VIRTUAL
  93. // Implementation
  94. protected:
  95. //{{AFX_MSG(CAboutDlg)
  96. // No message handlers
  97. //}}AFX_MSG
  98. DECLARE_MESSAGE_MAP()
  99. };
  100. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  101. {
  102. //{{AFX_DATA_INIT(CAboutDlg)
  103. //}}AFX_DATA_INIT
  104. }
  105. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  106. {
  107. CDialog::DoDataExchange(pDX);
  108. //{{AFX_DATA_MAP(CAboutDlg)
  109. //}}AFX_DATA_MAP
  110. }
  111. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  112. //{{AFX_MSG_MAP(CAboutDlg)
  113. // No message handlers
  114. //}}AFX_MSG_MAP
  115. END_MESSAGE_MAP()
  116. // App command to run the dialog
  117. void CDemoApp::OnAppAbout()
  118. {
  119. CAboutDlg aboutDlg;
  120. aboutDlg.DoModal();
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CDemoApp message handlers