MDI.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // MDI.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "MDI.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "Doc.h"
  8. #include "View.h"
  9. #include "about.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMDIApp
  17. BEGIN_MESSAGE_MAP(CMDIApp, CWinApp)
  18. //{{AFX_MSG_MAP(CMDIApp)
  19. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  20. //}}AFX_MSG_MAP
  21. // Standard file based document commands
  22. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  23. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  24. // Standard print setup command
  25. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CMDIApp construction
  29. CMDIApp::CMDIApp()
  30. {
  31. }
  32. /////////////////////////////////////////////////////////////////////////////
  33. // The one and only CMDIApp object
  34. CMDIApp theApp;
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CMDIApp initialization
  37. BOOL CMDIApp::InitInstance()
  38. {
  39. #ifdef _AFXDLL
  40. Enable3dControls(); // Call this when using MFC in a shared DLL
  41. #else
  42. Enable3dControlsStatic(); // Call this when linking to MFC statically
  43. #endif
  44. SetRegistryKey(_T("CodeProject"));
  45. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  46. // Register the application's document templates. Document templates
  47. // serve as the connection between documents, frame windows and views.
  48. CMultiDocTemplate* pDocTemplate;
  49. pDocTemplate = new CMultiDocTemplate(
  50. IDR_MDITYPE,
  51. RUNTIME_CLASS(CMDIDoc),
  52. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  53. RUNTIME_CLASS(CMDIView));
  54. AddDocTemplate(pDocTemplate);
  55. // create main MDI Frame window
  56. CMainFrame* pMainFrame = new CMainFrame;
  57. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  58. return FALSE;
  59. m_pMainWnd = pMainFrame;
  60. // Parse command line for standard shell commands, DDE, file open
  61. CCommandLineInfo cmdInfo;
  62. ParseCommandLine(cmdInfo);
  63. // Dispatch commands specified on the command line
  64. if (!ProcessShellCommand(cmdInfo))
  65. return FALSE;
  66. // The main window has been initialized, so show and update it.
  67. pMainFrame->ShowWindow(m_nCmdShow);
  68. pMainFrame->UpdateWindow();
  69. return TRUE;
  70. }
  71. // App command to run the dialog
  72. void CMDIApp::OnAppAbout()
  73. {
  74. CAboutDlg aboutDlg;
  75. aboutDlg.DoModal();
  76. }
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CMDIApp message handlers