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

📄 exgraphview.cpp

📁 用VC做的画椭圆程序....我自己做的
💻 CPP
字号:
// exgraphView.cpp : implementation of the CExgraphView class
//

#include "stdafx.h"
#include "exgraph.h"

#include "exgraphDoc.h"
#include "exgraphView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExgraphView

IMPLEMENT_DYNCREATE(CExgraphView, CView)

BEGIN_MESSAGE_MAP(CExgraphView, CView)
	//{{AFX_MSG_MAP(CExgraphView)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CExgraphView construction/destruction

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

}

CExgraphView::~CExgraphView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExgraphView drawing

void CExgraphView::OnDraw(CDC* pDC)
{
	CExgraphDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	int nindex;
	int numcircle = pDoc->GetCircleNum();
	if(numcircle)
	{
		CCircle * pencircle;
		for (nindex=0;nindex<numcircle;nindex++)
		{
			pencircle=pDoc->GetCircle(nindex);
			pencircle->Plot(pDC);
		}
	}
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CExgraphView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExgraphView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CExgraphView message handlers

void CExgraphView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_pold = point;
	SetCapture();
	CView::OnLButtonDown(nFlags, point);
}

void CExgraphView::OnLButtonUp(UINT nFlags, CPoint point) 
{
    if(GetCapture()==this)
		ReleaseCapture();
	this->Invalidate();
	CView::OnLButtonUp(nFlags, point);
}

void CExgraphView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if((nFlags & MK_LBUTTON)==MK_LBUTTON)
	{
		CClientDC dc(this);
		int radius = (int) (sqrt((point.x-m_pold.x)*
			(point.x-m_pold.x) + (point.y-m_pold.y)*
			(point.y-m_pold.y)));
		CCircle* pcircle = GetDocument()->AddCircle(m_pold,radius);
		pcircle->Plot(&dc);
	}
	CView::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

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