functionrectangle.cpp

来自「一个简单的画图程序 可以画点线面等」· C++ 代码 · 共 78 行

CPP
78
字号
// FunctionRectangle.cpp: implementation of the CFunctionRectangle class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FunctionRectangle.h"
#include "FunctionPolygon.h"
#include "MainFrm.h"
#include "SmallCAD203.h"
#include "SmallCAD203Doc.h"
#include "SmallCAD203View.h"


extern CSmallCAD203App theApp;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFunctionRectangle::CFunctionRectangle()
{
	l=NULL;
	mouseD=FALSE;
	ID=1;
}

CFunctionRectangle::~CFunctionRectangle()
{

}
void CFunctionRectangle::OnLButtonDown(UINT nFlags, CPoint point)
{
	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();
	mouseD=TRUE;
	l=new CGraphRectangle;
	l->SetColor(pDoc->GetCurrentColor());
	l->SetScale(pDoc->GetCurrentScale());
	CDC *pDC=pView->GetDC();
	l->SetPoint1(point);
	l->SetPoint2(point);
	l->Draw(pView->GetDC());
	pView->ReleaseDC(pDC);

}
void CFunctionRectangle::OnLButtonUp(UINT nFlags, CPoint point)
{
	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();
	
	CDC *pDC=pView->GetDC();
	mouseD=FALSE;
	l->SetPoint2(point);
	l->Draw(pView->GetDC());
	//pDoc->AddGraph(l);
	pDoc->my_list.InSert(l);
	pView->ReleaseDC(pDC);
}
void CFunctionRectangle::OnMouseMove(UINT nFlags, CPoint point)
{

	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();
	CDC *pDC=pView->GetDC();
//	pDC->SetROP2(R2_NOTXORPEN);

	if(!mouseD)
		return;
	pDC->SetROP2(R2_NOTXORPEN);
	l->Draw(pDC);
	l->SetPoint2(point);
	
	l->Draw(pDC);
	
	pView->ReleaseDC(pDC);
}	

⌨️ 快捷键说明

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