当前位置:   article > 正文

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

面向对象设计文档

1、实验目的

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

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

在这里插入图片描述

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_)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

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_)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

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 CMyMdiDoc::OnNewDocument()
{
   
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/
// CMyMdiDoc serialization

void CMyMdiDoc::Serialize(CArchive& ar)
{
   
	// CEditView contains an edit con
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/684777
推荐阅读
相关标签
  

闽ICP备14008679号