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

📄 outtex~2.cpp

📁 visual c++ 时尚编程百例 全部源代码
💻 CPP
字号:
// OutTextView.cpp : implementation of the COutTextView class
//

#include "stdafx.h"
#include "OutText.h"

#include "OutTextDoc.h"
#include "OutTextView.h"

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

/////////////////////////////////////////////////////////////////////////////
// COutTextView

IMPLEMENT_DYNCREATE(COutTextView, CView)

BEGIN_MESSAGE_MAP(COutTextView, CView)
	//{{AFX_MSG_MAP(COutTextView)
	ON_COMMAND(ID_VIEW_CENTER, OnViewCenter)
	ON_UPDATE_COMMAND_UI(ID_VIEW_CENTER, OnUpdateViewCenter)
	ON_COMMAND(ID_VIEW_LEFT, OnViewLeft)
	ON_UPDATE_COMMAND_UI(ID_VIEW_LEFT, OnUpdateViewLeft)
	ON_COMMAND(ID_VIEW_RIGHT, OnViewRight)
	ON_UPDATE_COMMAND_UI(ID_VIEW_RIGHT, OnUpdateViewRight)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// COutTextView construction/destruction

COutTextView::COutTextView()
{
	ResetAllFlags();
	m_bLeft=true;
	m_longfont.lfCharSet=DEFAULT_CHARSET;
	m_longfont.lfClipPrecision=CLIP_DEFAULT_PRECIS;
	m_longfont.lfEscapement=0;
	strcpy(m_longfont.lfFaceName,"Hello");
	m_longfont.lfHeight=90;
	m_longfont.lfItalic=false;
	m_longfont.lfOrientation=0;
	m_longfont.lfPitchAndFamily=FF_SWISS;
	m_longfont.lfQuality=DEFAULT_QUALITY;
	m_longfont.lfStrikeOut=false;
	m_longfont.lfUnderline=true;
	m_longfont.lfWeight=800;
	m_longfont.lfWidth=50;
	m_longfont.lfOutPrecision=OUT_DEFAULT_PRECIS;
	m_str="";



	// TODO: add construction code here

}

COutTextView::~COutTextView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// COutTextView drawing

void COutTextView::OnDraw(CDC* pDC)
{
	COutTextDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CRect rect;
	CFont font;
	CFont *pOldFont;
	UINT nDrawMode;
	nDrawMode=DT_WORDBREAK;
	if(m_bLeft)
		nDrawMode=nDrawMode|DT_LEFT;
	if(m_bRight)
		nDrawMode=nDrawMode|DT_RIGHT;
	if(m_bCenter)
		nDrawMode=nDrawMode|DT_CENTER;
	GetClientRect(&rect);
	font.CreateFontIndirect(&m_longfont);
	pOldFont=pDC->SelectObject(&font);
	m_str="Hello 网冠科技!";
	pDC->DrawText(m_str,&rect,nDrawMode);
	pDC->SelectObject(pOldFont);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// COutTextView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// COutTextView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// COutTextView message handlers
void COutTextView::ResetAllFlags()
{
m_bCenter=false;
m_bLeft=false;
m_bRight=false;
}

void COutTextView::OnViewCenter() 
{
	ResetAllFlags();
	m_bCenter=true;
	Invalidate();
	// TODO: Add your command handler code here
	
}

void COutTextView::OnUpdateViewCenter(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bCenter);
	// TODO: Add your command update UI handler code here
	
}

void COutTextView::OnViewLeft() 
{
	ResetAllFlags();
	m_bLeft=true;
	Invalidate();
	// TODO: Add your command handler code here
	
}

void COutTextView::OnUpdateViewLeft(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bLeft);
	// TODO: Add your command update UI handler code here
	
}

void COutTextView::OnViewRight() 
{
	ResetAllFlags();
	m_bRight=true;
	Invalidate();
	// TODO: Add your command handler code here
	
}

void COutTextView::OnUpdateViewRight(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bRight);
	// TODO: Add your command update UI handler code here
	
}

⌨️ 快捷键说明

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