www.pudn.com > DrawTrend.zip > DrawTrendView.cpp


// DrawTrendView.cpp : implementation of the CDrawTrendView class 
// 
 
#include "stdafx.h" 
#include "DrawTrend.h" 
 
#include "DrawTrendDoc.h" 
#include "DrawTrendView.h" 
#include "CyPaintBox.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView 
 
IMPLEMENT_DYNCREATE(CDrawTrendView, CView) 
 
BEGIN_MESSAGE_MAP(CDrawTrendView, CView) 
	//{{AFX_MSG_MAP(CDrawTrendView) 
	ON_WM_PAINT() 
	//}}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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView construction/destruction 
 
CDrawTrendView::CDrawTrendView() 
{ 
	// TODO: add construction code here 
 
} 
 
CDrawTrendView::~CDrawTrendView() 
{ 
} 
 
BOOL CDrawTrendView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView drawing 
 
void CDrawTrendView::OnDraw(CDC* pDC) 
{ 
	CDrawTrendDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView printing 
 
BOOL CDrawTrendView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CDrawTrendView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CDrawTrendView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView diagnostics 
 
#ifdef _DEBUG 
void CDrawTrendView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CDrawTrendView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CDrawTrendDoc* CDrawTrendView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawTrendDoc))); 
	return (CDrawTrendDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CDrawTrendView message handlers 
 
void CDrawTrendView::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
	TCyPaintBox * pclDrawTrend = new TCyPaintBox; 
	pclDrawTrend->SetDC(dc); 
 
	// 一条直线 
	CPoint clStartPoint, clEndPoint; 
	clStartPoint.x = 100; 
	clStartPoint.y = 300; 
 
	clEndPoint.x = 200; 
	clEndPoint.y = 300; 
 
	pclDrawTrend->Line(clStartPoint, clEndPoint, RGB(230, 34, 13)); 
 
	// 无填充色的框: 
	// 入参:起点x、起点y、宽、高 
	pclDrawTrend->Rect(100, 100, 100, 100, false, RGB(50, 82, 192)); 
	 
	// 有填充色的框 
	pclDrawTrend->Rect(300, 100, 100, 100, true, RGB(50, 82, 192)); 
	 
 
 
	delete pclDrawTrend; 
	pclDrawTrend = NULL; 
	// Do not call CView::OnPaint() for painting messages 
}