【VC开源代码栏目提醒】:网学会员VC开源代码为您提供CPaint_8View.cpp参考,解决您在CPaint_8View.cpp学习中工作中的难题,参考学习。
// CPaint_8View.cpp : implementation of the CCPaint_8View class
//
#include "stdafx.h"
#include "CPaint_8.h"
#include "CPaint_8Doc.h"
#include "CPaint_8View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View
IMPLEMENT_DYNCREATE(CCPaint_8View, CView)
BEGIN_MESSAGE_MAP(CCPaint_8View, CView)
//{{AFX_MSG_MAP(CCPaint_8View)
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()
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View construction/destruction
CCPaint_8View::CCPaint_8View()
{
// TODO: add construction code here
}
CCPaint_8View::~CCPaint_8View()
{
}
BOOL CCPaint_8View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View drawing
void CCPaint_8View::OnDraw(CDC* pDC)
{
CCPaint_8Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View printing
BOOL CCPaint_8View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCPaint_8View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCPaint_8View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View diagnostics
#ifdef _DEBUG
void CCPaint_8View::AssertValid() const
{
CView::AssertValid();
}
void CCPaint_8View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCPaint_8Doc* CCPaint_8View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCPaint_8Doc)));
return (CCPaint_8Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCPaint_8View message handlers
void CCPaint_8View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
TRIVERTEX vert[4];
GRADIENT_TRIANGLE gTRi[2];
vert[0].x=0; //四边形第一个顶点坐标
vert[0].y=0;
vert[0].Red=0xff00;
vert[0].Green=0xff00;
vert[0].Blue=0xff00;
vert[0].Alpha=0x0000;
vert[1].x=300; //四边形第二个顶点坐标
vert[1].y=0;
vert[1].Red=0xff00;
vert[1].Green=0x0000;
vert[1].Blue=0x0000;
vert[1].Alpha=0x0000;
vert[2].x=220; //四边形第三个顶点坐标
vert[2].y=150;
vert[2].Red=0x0000;
vert[2].Green=0xff00;
vert[2].Blue=0x0000;
vert[2].Alpha=0x0000;
vert[3].x=0; //四边形第四个顶点坐标
vert[3].y=100;
vert[3].Red=0x0000;
vert[3].Green=0x0000;
vert[3].Blue=0xff00;
vert[3].Alpha=0x0000;
gTRi[0].Vertex1=0;
gTRi[0].Vertex2=1;
gTRi[0].Vertex3=2;
gTRi[1].Vertex1=0;
gTRi[1].Vertex2=2;
gTRi[1].Vertex3=3;
GradientFill(dc.GetSafeHdc(),vert,4,&gTRi,2,GRADIENT_FILL_TRIANGLE);
//填充四边形
// Do not call CView::OnPaint() for painting messages
}
上一篇:
CPaint_8Doc.cpp
下一篇:
还记得,那年的风车吗?