Demo.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 "DemoDoc.h"
  7. #include "DemoView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CDemoApp
  15. BEGIN_MESSAGE_MAP(CDemoApp, CWinApp)
  16. //{{AFX_MSG_MAP(CDemoApp)
  17. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  18. //}}AFX_MSG_MAP
  19. // Standard file based document commands
  20. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  21. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  22. END_MESSAGE_MAP()
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CDemoApp construction
  25. CDemoApp::CDemoApp()
  26. {
  27. }
  28. /////////////////////////////////////////////////////////////////////////////
  29. // The one and only CDemoApp object
  30. CDemoApp theApp;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CDemoApp initialization
  33. BOOL CDemoApp::InitInstance()
  34. {
  35. // Standard initialization
  36. // Change the registry key under which our settings are stored.
  37. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  38. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  39. // Register document templates
  40. CSingleDocTemplate* pDocTemplate;
  41. pDocTemplate = new CSingleDocTemplate(
  42. IDR_MAINFRAME,
  43. RUNTIME_CLASS(CDemoDoc),
  44. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  45. RUNTIME_CLASS(CDemoView));
  46. AddDocTemplate(pDocTemplate);
  47. // Parse command line for standard shell commands, DDE, file open
  48. CCommandLineInfo cmdInfo;
  49. ParseCommandLine(cmdInfo);
  50. // Dispatch commands specified on the command line
  51. if (!ProcessShellCommand(cmdInfo))
  52. return FALSE;
  53. m_pMainWnd->ShowWindow(SW_SHOW);
  54. m_pMainWnd->UpdateWindow();
  55. return TRUE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CAboutDlg dialog used for App About
  59. class CAboutDlg : public CDialog
  60. {
  61. public:
  62. CAboutDlg();
  63. // Dialog Data
  64. //{{AFX_DATA(CAboutDlg)
  65. enum { IDD = IDD_ABOUTBOX };
  66. //}}AFX_DATA
  67. // ClassWizard generated virtual function overrides
  68. //{{AFX_VIRTUAL(CAboutDlg)
  69. protected:
  70. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  71. //}}AFX_VIRTUAL
  72. // Implementation
  73. protected:
  74. //{{AFX_MSG(CAboutDlg)
  75. // No message handlers
  76. //}}AFX_MSG
  77. DECLARE_MESSAGE_MAP()
  78. };
  79. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  80. {
  81. //{{AFX_DATA_INIT(CAboutDlg)
  82. //}}AFX_DATA_INIT
  83. }
  84. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  85. {
  86. CDialog::DoDataExchange(pDX);
  87. //{{AFX_DATA_MAP(CAboutDlg)
  88. //}}AFX_DATA_MAP
  89. }
  90. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  91. //{{AFX_MSG_MAP(CAboutDlg)
  92. // No message handlers
  93. //}}AFX_MSG_MAP
  94. END_MESSAGE_MAP()
  95. // App command to run the dialog
  96. void CDemoApp::OnAppAbout()
  97. {
  98. CAboutDlg aboutDlg;
  99. aboutDlg.DoModal();
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CDemoApp message handlers