www.pudn.com > work12_2.rar > yong24View.cpp


// yong24View.cpp : implementation of the CYong24View class 
// 
 
#include "stdafx.h" 
#include "yong24.h" 
 
#include "yong24Doc.h" 
#include "yong24View.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
extern COLORREF PenColor; 
extern int nline,ndraw,nrect,ntuoyuan; 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View 
 
IMPLEMENT_DYNCREATE(CYong24View, CView) 
 
BEGIN_MESSAGE_MAP(CYong24View, CView) 
	//{{AFX_MSG_MAP(CYong24View) 
	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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View construction/destruction 
 
CYong24View::CYong24View() 
{ 
	// TODO: add construction code here 
 
} 
 
CYong24View::~CYong24View() 
{ 
} 
 
BOOL CYong24View::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View drawing 
 
void CYong24View::OnDraw(CDC* pDC) 
{ 
	CYong24Doc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View printing 
 
BOOL CYong24View::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CYong24View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CYong24View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View diagnostics 
 
#ifdef _DEBUG 
void CYong24View::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CYong24View::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CYong24Doc* CYong24View::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CYong24Doc))); 
	return (CYong24Doc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CYong24View message handlers 
 
void CYong24View::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
//	CDC *pDC=GetDC(); 
		 
	CPtemp=point; 
	CView::OnLButtonDown(nFlags, point); 
} 
 
void CYong24View::OnLButtonUp(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CDC *pDC=GetDC(); 
	CPen pen(0,1,PenColor); 
	CPen *oldpen=pDC->SelectObject (&pen); 
	if(nline) 
	{ 
	pDC->MoveTo (CPtemp); 
	pDC->LineTo (point); 
	} 
	if(nrect) 
	{ 
		pDC->Rectangle(CPtemp.x,CPtemp.y,point.x,point.y); 
	} 
	if(ntuoyuan) 
	{ 
		pDC->Arc(CPtemp.x,CPtemp.y,point.x,point.y,0,0,0,0); 
	} 
	pDC->SelectObject (oldpen); 
	CView::OnLButtonUp(nFlags, point); 
} 
 
void CYong24View::OnMouseMove(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CDC *pDC=GetDC(); 
	if((nFlags==MK_LBUTTON)&&(ndraw==1)) 
		pDC->SetPixelV(point,PenColor); 
	CView::OnMouseMove(nFlags, point); 
}