【VC开源代码栏目提醒】:网学会员VC开源代码为您提供CText_4View.cpp参考,解决您在CText_4View.cpp学习中工作中的难题,参考学习。
// CText_4View.cpp : implementation of the CCText_4View class
//
#include "stdafx.h"
#include "CText_4.h"
#include "CText_4Doc.h"
#include "CText_4View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCText_4View
IMPLEMENT_DYNCREATE(CCText_4View, CView)
BEGIN_MESSAGE_MAP(CCText_4View, CView)
//{{AFX_MSG_MAP(CCText_4View)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCText_4View construction/destruction
CCText_4View::CCText_4View()
{
// TODO: add construction code here
}
CCText_4View::~CCText_4View()
{
}
BOOL CCText_4View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCText_4View drawing
void CCText_4View::OnDraw(CDC* pDC)
{
CCText_4Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CString str("Hello,World!");
CSize sz=pDC->GetTextExtent(str);
pDC->TextOut(50,50,str);
pDC->BeginPath(); //初始路径层
pDC->Rectangle(50,50,50+sz.cx,50+sz.cy);
pDC->EndPath(); //路径层结束
pDC->SelectClipPath(RGN_DIFF);
for(int i=0;i<200;i+=10)
{
pDC->MoveTo(0,i);
pDC->LineTo(200,i);
pDC->MoveTo(i,0);
pDC->LineTo(i,200);
}
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCText_4View printing
BOOL CCText_4View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCText_4View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCText_4View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCText_4View diagnostics
#ifdef _DEBUG
void CCText_4View::AssertValid() const
{
CView::AssertValid();
}
void CCText_4View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCText_4Doc* CCText_4View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCText_4Doc)));
return (CCText_4Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCText_4View message handlers