⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dshlinvw.cpp

📁 C:Documents and SettingsAdministrator桌面VC++多媒体特效制作百例CHAR01DASHLINE
💻 CPP
字号:
// DshLView.cpp : implementation of the CDashLineView class
//

#include "stdafx.h"
#include "DashLine.h"

#include "DshLDoc.h"
#include "DshLView.h"
#include "Line.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDashLineView

IMPLEMENT_DYNCREATE(CDashLineView, CView)

BEGIN_MESSAGE_MAP(CDashLineView, CView)
	//{{AFX_MSG_MAP(CDashLineView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CDashLineView construction/destruction

CDashLineView::CDashLineView()
{
	// TODO: add construction code here

}

CDashLineView::~CDashLineView()
{
}

BOOL CDashLineView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDashLineView drawing

void CDashLineView::OnDraw(CDC* pDC)
{
  CDashLineDoc* pDoc = GetDocument();
  ASSERT_VALID(pDoc);

  static int Type1[4] = { 100,  20,  20,  20 };
  static int Type2[4] = {  40,  40,  40,  40 };
  static int Type3[4] = { 100, 100, 100, 100 };
  static int Type4[4] = { 100,  30, 100,  30 };

  CRect rect; GetClientRect(&rect);
  
  // save the current pen before using DashLine
  CPen *pOldPen = pDC->GetCurrentPen();

  CDashLine Line1(pDC, RGB(255,0,0), RGB(0,255,0), 3, Type1);
  Line1.MoveTo(rect.left, rect.top);
  Line1.LineTo(rect.right, rect.bottom);

  CDashLine Line2(pDC, RGB(0,255,0), RGB(0,0,255), 3, Type2);
  Line2.MoveTo(rect.left, rect.bottom);
  Line2.LineTo(rect.right, rect.top);

  CDashLine Line3(pDC, RGB(255,255,0), RGB(0,255,255), 5, Type3);
  Line3.MoveTo(rect.left+10,  rect.bottom-10);
  Line3.LineTo(rect.right-10, rect.bottom-10);
  Line3.LineTo(rect.right-10, rect.top+10);
  Line3.LineTo(rect.left+10,  rect.top+10);
  Line3.LineTo(rect.left+10,  rect.bottom-10);

  CDashLine Line4(pDC, RGB(0,0,0), RGB(0,0,0), 3, Type4);
  Line4.MoveTo(rect.left,  rect.Height() / 2);
  Line4.LineTo(rect.right, rect.Height() / 2);

  // restore the pen
  pDC->SelectObject(pOldPen);
}

/////////////////////////////////////////////////////////////////////////////
// CDashLineView printing

BOOL CDashLineView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDashLineView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDashLineView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDashLineView diagnostics

#ifdef _DEBUG
void CDashLineView::AssertValid() const
{
	CView::AssertValid();
}

void CDashLineView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CDashLineDoc* CDashLineView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDashLineDoc)));
	return (CDashLineDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDashLineView message handlers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -