CText2.cpp
上传用户:jxd368
上传日期:2013-06-20
资源大小:66k
文件大小:3k
源码类别:

文本生成

开发平台:

Visual C++

  1. // CText2.cpp : 定义应用程序的类行为。
  2. //
  3. #include "stdafx.h"
  4. #include "CText2.h"
  5. #include "MainFrm.h"
  6. #include "CText2Doc.h"
  7. #include "CText2View.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11. // CCText2App
  12. BEGIN_MESSAGE_MAP(CCText2App, CWinApp)
  13. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  14. // 基于文件的标准文档命令
  15. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  16. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  17. // 标准打印设置命令
  18. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  19. END_MESSAGE_MAP()
  20. // CCText2App 构造
  21. CCText2App::CCText2App()
  22. {
  23. // TODO: 在此处添加构造代码,
  24. // 将所有重要的初始化放置在 InitInstance 中
  25. }
  26. // 唯一的一个 CCText2App 对象
  27. CCText2App theApp;
  28. // CCText2App 初始化
  29. BOOL CCText2App::InitInstance()
  30. {
  31. // 如果一个运行在 Windows XP 上的应用程序清单指定要
  32. // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
  33. //则需要 InitCommonControls()。否则,将无法创建窗口。
  34. InitCommonControls();
  35. CWinApp::InitInstance();
  36. // 初始化 OLE 库
  37. if (!AfxOleInit())
  38. {
  39. AfxMessageBox(IDP_OLE_INIT_FAILED);
  40. return FALSE;
  41. }
  42. AfxEnableControlContainer();
  43. // 标准初始化
  44. // 如果未使用这些功能并希望减小
  45. // 最终可执行文件的大小,则应移除下列
  46. // 不需要的特定初始化例程
  47. // 更改用于存储设置的注册表项
  48. // TODO: 应适当修改该字符串,
  49. // 例如修改为公司或组织名
  50. SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
  51. LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU)
  52. // 注册应用程序的文档模板。文档模板
  53. // 将用作文档、框架窗口和视图之间的连接
  54. CSingleDocTemplate* pDocTemplate;
  55. pDocTemplate = new CSingleDocTemplate(
  56. IDR_MAINFRAME,
  57. RUNTIME_CLASS(CCText2Doc),
  58. RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
  59. RUNTIME_CLASS(CCText2View));
  60. if (!pDocTemplate)
  61. return FALSE;
  62. AddDocTemplate(pDocTemplate);
  63. // 分析标准外壳命令、DDE、打开文件操作的命令行
  64. CCommandLineInfo cmdInfo;
  65. ParseCommandLine(cmdInfo);
  66. // 调度在命令行中指定的命令。如果
  67. // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
  68. if (!ProcessShellCommand(cmdInfo))
  69. return FALSE;
  70. // 唯一的一个窗口已初始化,因此显示它并对其进行更新
  71. m_pMainWnd->ShowWindow(SW_SHOW);
  72. m_pMainWnd->UpdateWindow();
  73. // 仅当存在后缀时才调用 DragAcceptFiles,
  74. //  在 SDI 应用程序中,这应在 ProcessShellCommand  之后发生
  75. return TRUE;
  76. }
  77. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  78. class CAboutDlg : public CDialog
  79. {
  80. public:
  81. CAboutDlg();
  82. // 对话框数据
  83. enum { IDD = IDD_ABOUTBOX };
  84. protected:
  85. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
  86. // 实现
  87. protected:
  88. DECLARE_MESSAGE_MAP()
  89. };
  90. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  91. {
  92. }
  93. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  94. {
  95. CDialog::DoDataExchange(pDX);
  96. }
  97. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  98. END_MESSAGE_MAP()
  99. // 用于运行对话框的应用程序命令
  100. void CCText2App::OnAppAbout()
  101. {
  102. CAboutDlg aboutDlg;
  103. aboutDlg.DoModal();
  104. }
  105. // CCText2App 消息处理程序