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

📄 exp22_1view.cpp

📁 mfc实验例题也是高教得配套资料 刚找到得 这部分应该是自学的内容
💻 CPP
字号:
// Exp22_1View.cpp : implementation of the CExp22_1View class
//

#include "stdafx.h"
#include "Exp22_1.h"

#include "Exp22_1Doc.h"
#include "Exp22_1View.h"
#include "graphdlg.h"

#include "line.h"
#include "arc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View

IMPLEMENT_DYNCREATE(CExp22_1View, CView)

BEGIN_MESSAGE_MAP(CExp22_1View, CView)
	//{{AFX_MSG_MAP(CExp22_1View)
	ON_COMMAND(ID_GRAPH, OnGraph)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View construction/destruction

CExp22_1View::CExp22_1View()
{
	// TODO: add construction code here

}

CExp22_1View::~CExp22_1View()
{
}

BOOL CExp22_1View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View drawing

void CExp22_1View::OnDraw(CDC* pDC)
{
	CExp22_1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	pDC->SetBkMode(OPAQUE);
	pDC->SelectStockObject(NULL_BRUSH);
	POSITION pos;
	CElement *elem;
	
	pos = m_pViewList->GetHeadPosition();
	while(pos!=NULL){
		elem = (CElement*)m_pViewList->GetAt(pos);
		elem->Draw(pDC);
		m_pViewList->GetNext(pos);
	}
	
}

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View printing

BOOL CExp22_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CExp22_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CExp22_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View diagnostics

#ifdef _DEBUG
void CExp22_1View::AssertValid() const
{
	CView::AssertValid();
}

void CExp22_1View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CExp22_1Doc* CExp22_1View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExp22_1Doc)));
	return (CExp22_1Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CExp22_1View message handlers

void CExp22_1View::OnGraph() 
{
	// TODO: Add your command handler code here
	CGraphDlg dlg;
	
	if((dlg.DoModal())==IDOK){
		m_color = RGB(dlg.m_intRed,dlg.m_intGreen,dlg.m_intBlue);
		m_type = dlg.m_intType ;
		if(m_type ==0){
			CLine *pLine = new CLine(dlg.m_intX1,dlg.m_intY1,dlg.m_intX2,dlg.m_intY2);
			pLine->SetColor(m_color);
			m_position = m_pViewList->AddTail(pLine);
		}
		else {
			CCircle *pCircle = new CCircle(dlg.m_intX1,dlg.m_intY1,dlg.m_intX2);
			pCircle->SetColor(m_color);
			m_position = m_pViewList->AddTail(pCircle);
		}
	}
	Invalidate();
	
}

void CExp22_1View::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class

	CExp22_1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	m_pViewList = &(pDoc->m_elemList);
	m_position = m_pViewList->GetHeadPosition();
}

⌨️ 快捷键说明

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