tiancview.cpp

来自「图形学区域填充算法」· C++ 代码 · 共 151 行

CPP
151
字号
// tiancView.cpp : implementation of the CTiancView class
//

#include "stdafx.h"
#include "tianc.h"

#include "tiancDoc.h"
#include "tiancView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTiancView

IMPLEMENT_DYNCREATE(CTiancView, CView)

BEGIN_MESSAGE_MAP(CTiancView, CView)
	//{{AFX_MSG_MAP(CTiancView)
		// 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 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()

/////////////////////////////////////////////////////////////////////////////
// CTiancView construction/destruction

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

}

CTiancView::~CTiancView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTiancView drawing

void CTiancView::OnDraw(CDC* pDC)
{
	CTiancDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

    pDC->SetMapMode(MM_ISOTROPIC);
	pDC->SetViewportOrg(10,400);
	pDC->MoveTo(0,0);
	pDC->LineTo(2200,0);
	pDC->MoveTo(0,0);
	pDC->LineTo(0,1200);

    POINT p1,p2,p3,p4,p5,p6;
	p1.x=200,p1.y=200;
	p2.x=500,p2.y=100;
	p3.x=1100,p3.y=300;
	p4.x=1100,p4.y=800;
	p5.x=500,p5.y=500;
	p6.x=200,p6.y=700;
    
	HPEN pen;
	pen=CreatePen(PS_SOLID,0,RGB(255,0,0));
	pDC->SelectObject(pen);

	pDC->MoveTo(p1);
	pDC->LineTo(p2);
	pDC->LineTo(p3);
	pDC->LineTo(p4);
	pDC->LineTo(p5);
	pDC->LineTo(p6);
	pDC->LineTo(p1);
   
    CBrush brush;
	brush.CreateSolidBrush(RGB(255,255,0));
	pDC->SelectObject(brush);
	
	pDC->Rectangle(p1.x,p1.y,800-10,100);
	
	pDC->Rectangle(200,300,1100-10,200);
    
	pDC->Rectangle(200,400,1100-10,300);
    
	pDC->Rectangle(200,500,1100-10,400);

	pDC->Rectangle(200,600,350-10,500);
	
	pDC->Rectangle(700,600,1100-10,500);
    
	pDC->Rectangle(900,700,1100-10,600);

}

/////////////////////////////////////////////////////////////////////////////
// CTiancView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CTiancView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CTiancView message handlers

⌨️ 快捷键说明

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