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

📄 testrotdcview.cpp

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

#include "stdafx.h"
#include "TestRotDC.h"

#include "TestRotDCDoc.h"
#include "TestRotDCView.h"

#include	"cdxCRot90DC.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestRotDCView

IMPLEMENT_DYNCREATE(CTestRotDCView, CView)

BEGIN_MESSAGE_MAP(CTestRotDCView, CView)
	//{{AFX_MSG_MAP(CTestRotDCView)
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestRotDCView construction/destruction

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

}

CTestRotDCView::~CTestRotDCView()
{
}

BOOL CTestRotDCView::PreCreateWindow(CREATESTRUCT& cs)
{
	cs.style	|=	WS_CLIPCHILDREN;
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTestRotDCView drawing

/*
 * calls "DrawRot()" for each rectangle
 */

void CTestRotDCView::OnDraw(CDC* pDC)
{
	CTestRotDCDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// get current client rect
	CRect	rectClient,rect;
	CSize	sz;
	GetClientRect(rectClient);

	//
	// create a normal memory device context
	//

	cdxCRot90DC	memDC(pDC,rectClient,0);
	COLORREF		ct	=	memDC.SetTextColor(RGB(160,0,0)),
					cb	=	memDC.GetBkColor();

	// fill with background (FillSolidRect() changes the bk color)
	// note that I've modified OnEraseBkGnd()
	memDC.FillSolidRect(rectClient,RGB(255,255,255));

	// draw header text
	CString	s	=	_T("This is an example on how to use cdxCRot90DC.\n"
							"It illustrates:\n"
							" a) How to use it as a replacement for a standard \"CMemDC\".\n"
							"    (member \"memDC\" in OnDraw()).\n"
							" b) How to use it to draw rotated stuff and how to re-use it.\n"
							"    Note that another function Draw() is used to perform the drawing.");

	rect	=	rectClient;
	int	i	=	memDC.DrawText(s,rect,DT_CALCRECT|DT_LEFT|DT_END_ELLIPSIS|DT_WORDBREAK);
	rect.top		+=	5;
	rect.bottom	=	rect.top + i;
	i	=	rect.Width();
	rect.left	=	rectClient.left + (rectClient.Width() - i) / 2;
	rect.right	=	rect.left + i;
	memDC.DrawText(s,rect,DT_LEFT|DT_END_ELLIPSIS|DT_WORDBREAK);

	//
	// some calculations to render my 4 rectangles
	//

	rectClient.top	=	rect.bottom + 5;
	sz	=	rectClient.Size();
	sz.cx	/=	5;
	sz.cy	/=	5;

	//
	// draw rotated rects
	//

	cdxCRot90DC	rotDC;

	// draw 0

⌨️ 快捷键说明

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