面向对象程序设计——多文档综合性试验

这篇具有很好参考价值的文章主要介绍了面向对象程序设计——多文档综合性试验。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、实验目的

1)创建一个多文档应用程序MyMdi,可以在这个多文档中可以输入文本、显示静态图、动态图以及显示对话框进行操作。
2)第一个视图类的基类为CEditView(CView的子类),可以录入字符串。
3)第二个文档画出静态图,包括五种以上图形。
4)在第二个文档菜单栏“画图”中点击“动态图”可以实现动态画图。,点击“清空”可以将所有内容清空。
5)在第二个文档里画出静态图或动态图可以右击使用橡皮进行擦除。
在第三个文档菜单栏“编辑”中点击某一项可以打开对话框,至少有5种控件存放学生信息,并且每种控件内的信息读取后可以在辑框中显示出来。并且显示信息后可以实现串行化,实现输入、保存并显示信息。

2、各个类的继承关系结构图。

面向对象程序设计——多文档综合性试验文章来源地址https://www.toymoban.com/news/detail-491804.html

3、每个类的定义,包括.h文件和.cpp文件。

1)MyMdi.h

// MyMdi.h : main header file for the MYMDI application
//
#if !defined(AFX_MYMDI_H__2FBCC3E9_F38E_41C1_B7A8_0EBBBFA73891__INCLUDED_)
#define AFX_MYMDI_H__2FBCC3E9_F38E_41C1_B7A8_0EBBBFA73891__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols

/
// CMyMdiApp:
// See MyMdi.cpp for the implementation of this class
//

class CMyMdiApp : public CWinApp
{
   
public:
	CMyMdiApp();

// Overrides
	// ClassWizard generated virtual function overrides
	//{
   {AFX_VIRTUAL(CMyMdiApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL

// Implementation
	//{
   {AFX_MSG(CMyMdiApp)
	afx_msg void OnAppAbout();
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/

//{
   {AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYMDI_H__2FBCC3E9_F38E_41C1_B7A8_0EBBBFA73891__INCLUDED_)

2)MyMdi.cpp

// MyMdi.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "MyMdi.h"

#include "MainFrm.h"
#include "ChildFrm.h"
#include "MyMdiDoc.h"
#include "MyMdiView.h"
#include "MyMdiDoc2.h"		//加入头文件
#include "MyMdiView2.h"
#include "MyMdiDoc3.h"		//加入头文件
#include "MyMdiView3.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/
// CMyMdiApp

BEGIN_MESSAGE_MAP(CMyMdiApp, CWinApp)
	//{
   {AFX_MSG_MAP(CMyMdiApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/
// CMyMdiApp construction

CMyMdiApp::CMyMdiApp()
{
   
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/
// The one and only CMyMdiApp object

CMyMdiApp theApp;

/
// CMyMdiApp initialization

BOOL CMyMdiApp::InitInstance()
{
   
	AfxEnableControlContainer();


	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_MYMDITYPE,
		RUNTIME_CLASS(CMyMdiDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CMyMdiView));
	AddDocTemplate(pDocTemplate);

	CMultiDocTemplate* pDocTemplate2;
pDocTemplate2 = new CMultiDocTemplate(
IDR_MYMDITYPE2,
RUNTIME_CLASS(CMyMdiDoc2), // MDI派生文档类的CRuntimeClass对象的指针
RUNTIME_CLASS(CChildFrame), // MDI派生子框架类的CRuntimeClass对象的指针
RUNTIME_CLASS(CMyMdiView2)); // 创建文档模板对象
AddDocTemplate(pDocTemplate2); //将新模板添加到应用程序的文档模板列表中

CMultiDocTemplate* pDocTemplate3;
	pDocTemplate3 = new CMultiDocTemplate(
		IDR_MYMDITYPE3,
		RUNTIME_CLASS(CMyMdiDoc3),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CMyMdiView3));
	AddDocTemplate(pDocTemplate3);


	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}


/
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
   
public:
	CAboutDlg();

// Dialog Data
	//{
   {AFX_DATA(CAboutDlg)
	enum {
    IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{
   {AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{
   {AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
   
	//{
   {AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
   
	CDialog::DoDataExchange(pDX);
	//{
   {AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{
   {AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CMyMdiApp::OnAppAbout()
{
   
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/
// CMyMdiApp message handlers

3)MyMdiDoc.h

// MyMdiDoc.h : interface of the CMyMdiDoc class
//
/

#if !defined(AFX_MYMDIDOC_H__4CCFC2E0_9D27_4259_8C68_45099862CD8E__INCLUDED_)
#define AFX_MYMDIDOC_H__4CCFC2E0_9D27_4259_8C68_45099862CD8E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CMyMdiDoc : public CDocument
{
   
protected: // create from serialization only
	CMyMdiDoc();
	DECLARE_DYNCREATE(CMyMdiDoc)

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{
   {AFX_VIRTUAL(CMyMdiDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMyMdiDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{
   {AFX_MSG(CMyMdiDoc)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/

//{
   {AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYMDIDOC_H__4CCFC2E0_9D27_4259_8C68_45099862CD8E__INCLUDED_)

4)MyMdiDoc.cpp

// MyMdiDoc.cpp : implementation of the CMyMdiDoc class
//

#include "stdafx.h"
#include "MyMdi.h"

#include "MyMdiDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/
// CMyMdiDoc

IMPLEMENT_DYNCREATE(CMyMdiDoc, CDocument)

BEGIN_MESSAGE_MAP(CMyMdiDoc, CDocument)
	//{
   {AFX_MSG_MAP(CMyMdiDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/
// CMyMdiDoc construction/destruction

CMyMdiDoc::CMyMdiDoc()
{
   
	// TODO: add one-time construction code here

}

CMyMdiDoc::~CMyMdiDoc()
{
   
}

BOOL 

到了这里,关于面向对象程序设计——多文档综合性试验的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Python-基础篇-类与对象/面向对象程序设计

    “类”是物以类聚的 “类” 类 和 对象 是 面向对象编程的 两个 核心概念 类 是对一群具有 相同 特征 或者 行为 的事物的一个统称,是抽象的, 不能直接使用 特征 被称为 属性 行为 被称为 方法 类 就相当于制造飞机时的 图纸 ,是一个 模板 ,是 负责创建对象的 定义类📚

    2024年01月19日
    浏览(41)
  • 面向对象程序设计第三次bolg

    本次博客针对面向对象程序设计的课程所发的PTA作业7,8以及期末考试中的面向对象编程题的分析和总结,重点介绍课程成绩统计程序系列题目以及期末考试的编程题。 在这次作业中7-1、7-2内容和考点相同,在此我分析一下7-2Hashmap的排序这个问题。 7-2 容器-HashMap-排序 分数

    2024年02月05日
    浏览(44)
  • 面向对象程序设计 之 文件输入输出流

    石 家 庄 铁 道 大 学 实 验 报 告 课程名称 面向对象程序设计 班级   姓名   学号   实验日期 2023.5.16 评分 100   实验项目名称:输入输出流 一、实验目的 掌握文本文件和二进制文件的基本访问方法; 了解一般I/O流和文件流的关系;了解文件与文件流的关系; 了解文件系统

    2024年02月05日
    浏览(35)
  • 2023.5.5 面向对象程序设计实验报告

    实验项目名称:模板 1、熟练掌握函数模板和类模板的定义格式。 2、熟练运用函数模板和类模板解决实际问题。 1、复数类Complex有两个数据成员:a和b, 分别代表复数的实部和虚部,并有若干构造函数和一个重载-(减号,用于计算两个复数的距离)的成员函数。 要求设计一个

    2024年02月02日
    浏览(102)
  • C++面向对象程序设计 - 类和对象进一步讨论

            在C++中,关于面向对象程序设计已经讲了很大篇幅,也例举很多案例,此篇将通过一些习题来进一步了解对象、静态成员、指针、引用、友元、类模板等等相关知识。         示例代码:         如上代码,运行后结果如下图:          现在将上述代码中,第

    2024年04月16日
    浏览(52)
  • C++面向对象程序设计 - 运算符重载

            函数重载就是对一个已有的函数赋予新的含义,使之实现新的功能。因此一个函数名就可以用来代表不同功能的函数,也就是一名多用。运算符也可以重载,即运算符重载(operator overloading)。         运算符重载的方法是定义一个重载运算符的函数,在需要执行被

    2024年04月25日
    浏览(31)
  • .NET 面向对象程序设计 —— 学习笔记 详细版

            开始考虑通过封装、继承、多态把程序的耦合度降低(传统印刷 术的问题就在于所有的字都刻在同一版面上造成耦合度太高所制),开始用设计模式使得程序更加的灵活,容易修改, 并且易于复用。         大鸟说:“且先不说出题人的意思,单就你现在的

    2024年04月26日
    浏览(26)
  • 【面向对象程序设计】账户类(Java、JavaFX)

    目录 版本1: 设计Account1类,包含: 设计测试类ATMMachine1: 版本2: 扩展Account1类为Account2类:   设计测试类ATMMachine2,其主菜单如下: 版本3: uml啥的找不到了,太久远了,有什么不懂得评论或者私聊问我吧。 ■ 一个名为id 的int 类型的私有数据域(默认值为0),长度为6位

    2024年02月08日
    浏览(31)
  • Java面向对象程序设计 - 清览云题库

    目录 清览题库1 清览题库2 清览题库3 清览题库4 清览题库5 1.   给出下列【代码】注释标注的代码的输出结果。 public class Example {    public static void main(String args[])  {       System.out.println(\\\"hello\\\"); //【代码】            } } 答案 hello 2.   给出下列【代码】注释标注的代码

    2024年02月08日
    浏览(37)
  • C++面向对象程序设计-基础入门(超详细)

    目录 一、c++概述 二、初识c++ 1、第一个c++程序  2、c++面向对象的三大特性(重要) 三、作用域运算符:: 1、使用namespace创建一个命名空间 2、命名空间只能定义在全局 3、 命名空间嵌套  4、随时将新的成员加入命名空间 5、命名空间中 函数的声明和实现分开   6、

    2024年02月16日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包