sample.cpp
上传用户:hicheon
上传日期:2007-02-06
资源大小:34k
文件大小:4k
源码类别:

ListView/ListBox

开发平台:

Visual C++

  1. // sample.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "ChooseDialog.h"
  6. #include "sample.h"
  7. #include "MainFrm.h"
  8. #include "sampleDoc.h"
  9. #include "sampleView.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CSampleApp
  17. BEGIN_MESSAGE_MAP(CSampleApp, CWinApp)
  18. //{{AFX_MSG_MAP(CSampleApp)
  19. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  20. // NOTE - the ClassWizard will add and remove mapping macros here.
  21. //    DO NOT EDIT what you see in these blocks of generated code!
  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. // Standard print setup command
  27. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  28. END_MESSAGE_MAP()
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CSampleApp construction
  31. CSampleApp::CSampleApp()
  32. {
  33. // TODO: add construction code here,
  34. // Place all significant initialization in InitInstance
  35. }
  36. /////////////////////////////////////////////////////////////////////////////
  37. // The one and only CSampleApp object
  38. CSampleApp theApp;
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CSampleApp initialization
  41. BOOL CSampleApp::InitInstance()
  42. {
  43. AfxEnableControlContainer();
  44. // Standard initialization
  45. // If you are not using these features and wish to reduce the size
  46. //  of your final executable, you should remove from the following
  47. //  the specific initialization routines you do not need.
  48. #ifdef _AFXDLL
  49. Enable3dControls(); // Call this when using MFC in a shared DLL
  50. #else
  51. Enable3dControlsStatic(); // Call this when linking to MFC statically
  52. #endif
  53. // Change the registry key under which our settings are stored.
  54. // TODO: You should modify this string to be something appropriate
  55. // such as the name of your company or organization.
  56. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  57. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  58. // Register the application's document templates.  Document templates
  59. //  serve as the connection between documents, frame windows and views.
  60. CChooseDialog dlg;
  61. if( dlg.DoModal() == IDOK )
  62. {
  63. if( dlg.m_optSingleSelection == 0 )
  64. m_bSingleSelection = true;
  65. else
  66. m_bSingleSelection = false;
  67. }
  68. else
  69. return FALSE;
  70. CSingleDocTemplate* pDocTemplate;
  71. pDocTemplate = new CSingleDocTemplate(
  72. IDR_MAINFRAME,
  73. RUNTIME_CLASS(CSampleDoc),
  74. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  75. RUNTIME_CLASS(CSampleView));
  76. AddDocTemplate(pDocTemplate);
  77. // Parse command line for standard shell commands, DDE, file open
  78. CCommandLineInfo cmdInfo;
  79. ParseCommandLine(cmdInfo);
  80. // Dispatch commands specified on the command line
  81. if (!ProcessShellCommand(cmdInfo))
  82. return FALSE;
  83. // The one and only window has been initialized, so show and update it.
  84. m_pMainWnd->ShowWindow(SW_SHOW);
  85. m_pMainWnd->UpdateWindow();
  86. return TRUE;
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CAboutDlg dialog used for App About
  90. class CAboutDlg : public CDialog
  91. {
  92. public:
  93. CAboutDlg();
  94. // Dialog Data
  95. //{{AFX_DATA(CAboutDlg)
  96. enum { IDD = IDD_ABOUTBOX };
  97. //}}AFX_DATA
  98. // ClassWizard generated virtual function overrides
  99. //{{AFX_VIRTUAL(CAboutDlg)
  100. protected:
  101. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  102. //}}AFX_VIRTUAL
  103. // Implementation
  104. protected:
  105. //{{AFX_MSG(CAboutDlg)
  106. // No message handlers
  107. //}}AFX_MSG
  108. DECLARE_MESSAGE_MAP()
  109. };
  110. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  111. {
  112. //{{AFX_DATA_INIT(CAboutDlg)
  113. //}}AFX_DATA_INIT
  114. }
  115. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  116. {
  117. CDialog::DoDataExchange(pDX);
  118. //{{AFX_DATA_MAP(CAboutDlg)
  119. //}}AFX_DATA_MAP
  120. }
  121. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  122. //{{AFX_MSG_MAP(CAboutDlg)
  123. // No message handlers
  124. //}}AFX_MSG_MAP
  125. END_MESSAGE_MAP()
  126. // App command to run the dialog
  127. void CSampleApp::OnAppAbout()
  128. {
  129. CAboutDlg aboutDlg;
  130. aboutDlg.DoModal();
  131. }
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CSampleApp message handlers