Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
3.3 KiB

  1. // mditest.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "mditest.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CMditestApp
  14. BEGIN_MESSAGE_MAP(CMditestApp, CWinApp)
  15. //{{AFX_MSG_MAP(CMditestApp)
  16. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  17. ON_COMMAND(ID_FILE_NEW, OnFileNew)
  18. //}}AFX_MSG_MAP
  19. END_MESSAGE_MAP()
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMditestApp construction
  22. CMditestApp::CMditestApp()
  23. {
  24. }
  25. /////////////////////////////////////////////////////////////////////////////
  26. // The one and only CMditestApp object
  27. CMditestApp theApp;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMditestApp initialization
  30. BOOL CMditestApp::InitInstance()
  31. {
  32. // Standard initialization
  33. #ifdef _AFXDLL
  34. Enable3dControls(); // Call this when using MFC in a shared DLL
  35. #else
  36. Enable3dControlsStatic(); // Call this when linking to MFC statically
  37. #endif
  38. // Change the registry key under which our settings are stored.
  39. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  40. CMDIFrameWnd* pFrame = new CMainFrame;
  41. m_pMainWnd = pFrame;
  42. // create main MDI frame window
  43. if (!pFrame->LoadFrame(IDR_MAINFRAME))
  44. return FALSE;
  45. // try to load shared MDI menus and accelerator table
  46. HINSTANCE hInst = AfxGetResourceHandle();
  47. m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_MDITESTYPE));
  48. m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MDITESTYPE));
  49. pFrame->ShowWindow(m_nCmdShow);
  50. pFrame->UpdateWindow();
  51. return TRUE;
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMditestApp message handlers
  55. int CMditestApp::ExitInstance()
  56. {
  57. if (m_hMDIMenu != NULL)
  58. FreeResource(m_hMDIMenu);
  59. if (m_hMDIAccel != NULL)
  60. FreeResource(m_hMDIAccel);
  61. return CWinApp::ExitInstance();
  62. }
  63. void CMditestApp::OnFileNew()
  64. {
  65. CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
  66. // create a new MDI child window
  67. pFrame->CreateNewChild(
  68. RUNTIME_CLASS(CChildFrame), IDR_MDITESTYPE, m_hMDIMenu, m_hMDIAccel);
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CAboutDlg dialog used for App About
  72. class CAboutDlg : public CDialog
  73. {
  74. public:
  75. CAboutDlg();
  76. // Dialog Data
  77. //{{AFX_DATA(CAboutDlg)
  78. enum { IDD = IDD_ABOUTBOX };
  79. //}}AFX_DATA
  80. // ClassWizard generated virtual function overrides
  81. //{{AFX_VIRTUAL(CAboutDlg)
  82. protected:
  83. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  84. //}}AFX_VIRTUAL
  85. // Implementation
  86. protected:
  87. //{{AFX_MSG(CAboutDlg)
  88. // No message handlers
  89. //}}AFX_MSG
  90. DECLARE_MESSAGE_MAP()
  91. };
  92. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  93. {
  94. //{{AFX_DATA_INIT(CAboutDlg)
  95. //}}AFX_DATA_INIT
  96. }
  97. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  98. {
  99. CDialog::DoDataExchange(pDX);
  100. //{{AFX_DATA_MAP(CAboutDlg)
  101. //}}AFX_DATA_MAP
  102. }
  103. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  104. //{{AFX_MSG_MAP(CAboutDlg)
  105. // No message handlers
  106. //}}AFX_MSG_MAP
  107. END_MESSAGE_MAP()
  108. // App command to run the dialog
  109. void CMditestApp::OnAppAbout()
  110. {
  111. CAboutDlg aboutDlg;
  112. aboutDlg.DoModal();
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CMditestApp message handlers