lineview.cpp
来自「本压缩软件为《Visual C++6.0基础教程》(黑魔方系列)一书的源代码」· C++ 代码 · 共 123 行
CPP
123 行
// LineView.cpp : implementation of the CLineView class
//
#include "stdafx.h"
#include "Line.h"
#include "LineDoc.h"
#include "LineView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLineView
IMPLEMENT_DYNCREATE(CLineView, CView)
BEGIN_MESSAGE_MAP(CLineView, CView)
//{{AFX_MSG_MAP(CLineView)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CLineView construction/destruction
CLineView::CLineView()
{
// TODO: add construction code here
}
CLineView::~CLineView()
{
}
BOOL CLineView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLineView drawing
void CLineView::OnDraw(CDC* pDC)
{
CLineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
ShowPen(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// CLineView printing
BOOL CLineView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CLineView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CLineView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CLineView diagnostics
#ifdef _DEBUG
void CLineView::AssertValid() const
{
CView::AssertValid();
}
void CLineView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CLineDoc* CLineView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLineDoc)));
return (CLineDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLineView message handlers
void CLineView::ShowPen(CDC *pDC)
{
UINT position=10;
int m=370,n=370;
for(int x=0; x<28 ;x++)
{
CPen pen(PS_SOLID, x*1.2,RGB(245,120,225));
CPen* oldPen=pDC->SelectObject (&pen);
position+=x*2+5;
pDC->MoveTo (m,position);
pDC->LineTo (n,position);
pDC->SelectObject (oldPen);
m=m-20;
n=n+20;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?