outtxtview.cpp

来自「Visual+C+++6[1].0实用教程代码 Visual+C+++6[1]」· C++ 代码 · 共 112 行

CPP
112
字号
// outtxtView.cpp : implementation of the COuttxtView class
//

#include "stdafx.h"
#include "outtxt.h"

#include "outtxtDoc.h"
#include "outtxtView.h"

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

/////////////////////////////////////////////////////////////////////////////
// COuttxtView

IMPLEMENT_DYNCREATE(COuttxtView, CView)

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

/////////////////////////////////////////////////////////////////////////////
// COuttxtView construction/destruction

COuttxtView::COuttxtView()
{
}

COuttxtView::~COuttxtView()
{
}

BOOL COuttxtView::PreCreateWindow(CREATESTRUCT& cs)
{
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// COuttxtView drawing

void COuttxtView::OnDraw(CDC* pDC)
{
	COuttxtDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
    int x, y;
    x = 100;
    y = 100;
    LPCTSTR lpszHello ="Hello ";
    LPCTSTR lpszWinXp = "Visual C++";

    // 画第一条直线。
    pDC->TextOut( x, y, lpszHello, strlen( lpszHello ) );

    //计算第一条直线的长度。
    CSize sizeString =pDC->GetTextExtent(lpszHello, strlen( lpszHello ));

    // 调整横坐标。
    x += sizeString.cx;

    // 画第二条直线。
   pDC->TextOut( x, y, lpszWinXp, strlen( lpszWinXp) );
}

/////////////////////////////////////////////////////////////////////////////
// COuttxtView printing

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

void COuttxtView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}

void COuttxtView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}

/////////////////////////////////////////////////////////////////////////////
// COuttxtView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// COuttxtView message handlers

⌨️ 快捷键说明

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