⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mydoc.cpp

📁 VC面向对象的学习教程
💻 CPP
字号:
// MyDoc.cpp : implementation of the CMyDoc class
//

#include "stdafx.h"
#include "My.h"

#include "MyDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyDoc

IMPLEMENT_DYNCREATE(CMyDoc, CDocument)

BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
	//{{AFX_MSG_MAP(CMyDoc)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMyDoc construction/destruction

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

}

CMyDoc::~CMyDoc()
{
}

BOOL CMyDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CMyDoc serialization

void CMyDoc::Serialize(CArchive& ar)
{
	for(int i=0; i<CHIP_COUNT; i++)
		m_chipList[i].Serialize(ar);
}

/////////////////////////////////////////////////////////////////////////////
// CMyDoc diagnostics

#ifdef _DEBUG
void CMyDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CMyDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyDoc commands
// 清理文档:关闭文档、建立新文档和打开文档前调用
void CMyDoc::DeleteContents() 
{
	// TODO: Add your specialized code here and/or call the base class
	Reset();	
	CDocument::DeleteContents();
}
// 初始化拼图块
void CMyDoc::Reset()
{
	POINT	pointList[MAX_POINTS];
	pointList[0].x = DELTA;
	pointList[0].y = DELTA;
	pointList[1].x = DELTA+CHIP_WIDTH;
	pointList[1].y = DELTA;
	pointList[2].x = DELTA+CHIP_WIDTH/2;
	pointList[2].y = DELTA+CHIP_WIDTH/2;
	m_chipList[0].SetChip(1, pointList, 3);

	pointList[0].x = DELTA;
	pointList[0].y = DELTA;
	pointList[1].x = DELTA;
	pointList[1].y = DELTA+CHIP_WIDTH;
	pointList[2].x = DELTA+CHIP_WIDTH/2;
	pointList[2].y = DELTA+CHIP_WIDTH/2;
	m_chipList[1].SetChip(2, pointList, 3);

	pointList[0].x = DELTA+CHIP_WIDTH;
	pointList[0].y = DELTA;
	pointList[1].x = DELTA+CHIP_WIDTH;
	pointList[1].y = DELTA+CHIP_WIDTH/2;
	pointList[2].x = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].y = DELTA+CHIP_WIDTH/4;
	m_chipList[2].SetChip(3, pointList, 3);

	pointList[0].x = DELTA+CHIP_WIDTH/2;
	pointList[0].y = DELTA+CHIP_WIDTH/2;
	pointList[1].x = DELTA+CHIP_WIDTH/4;
	pointList[1].y = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].x = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].y = DELTA+(CHIP_WIDTH*3)/4;
	m_chipList[3].SetChip(4, pointList, 3);

	pointList[0].x = DELTA+CHIP_WIDTH;
	pointList[0].y = DELTA+CHIP_WIDTH/2;
	pointList[1].x = DELTA+CHIP_WIDTH;
	pointList[1].y = DELTA+CHIP_WIDTH;
	pointList[2].x = DELTA+CHIP_WIDTH/2;
	pointList[2].y = DELTA+CHIP_WIDTH;
	m_chipList[4].SetChip(5, pointList, 3);

	pointList[0].x = DELTA+(CHIP_WIDTH*3)/4;
	pointList[0].y = DELTA+CHIP_WIDTH/4;
	pointList[1].x = DELTA+CHIP_WIDTH/2;
	pointList[1].y = DELTA+CHIP_WIDTH/2;
	pointList[2].x = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].y = DELTA+(CHIP_WIDTH*3)/4;
	pointList[3].x = DELTA+CHIP_WIDTH;
	pointList[3].y = DELTA+CHIP_WIDTH/2;
	m_chipList[5].SetChip(6, pointList, 4);

	pointList[0].x = DELTA;
	pointList[0].y = DELTA+CHIP_WIDTH;
	pointList[1].x = DELTA+CHIP_WIDTH/4;
	pointList[1].y = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].x = DELTA+(CHIP_WIDTH*3)/4;
	pointList[2].y = DELTA+(CHIP_WIDTH*3)/4;
	pointList[3].x = DELTA+CHIP_WIDTH/2;
	pointList[3].y = DELTA+CHIP_WIDTH;
	m_chipList[6].SetChip(7, pointList, 4);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -