📄 exampleview.cpp
字号:
// ExampleView.cpp : implementation of the CExampleView class
//
#include "stdafx.h"
#include "Example.h"
#include "ExampleDoc.h"
#include "ExampleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExampleView
IMPLEMENT_DYNCREATE(CExampleView, CView)
BEGIN_MESSAGE_MAP(CExampleView, CView)
//{{AFX_MSG_MAP(CExampleView)
// 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
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExampleView construction/destruction
CExampleView::CExampleView()
{
// TODO: add construction code here
}
CExampleView::~CExampleView()
{
}
BOOL CExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CExampleView drawing
void CExampleView::OnDraw(CDC* pDC)
{
CExampleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int nXStart=10, nYStart=10;
SIZE sz;
int nStrLen;
LPSTR lpsz="Hello";
CFont MyFont;
CFont *pOldFont;
MyFont.CreateFont(100, 40, 0, 0, FW_HEAVY, 1, 0,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "Times New Roman");
pOldFont=pDC->SelectObject(&MyFont);
pDC->BeginPath();
pDC->TextOut(nXStart, nYStart,lpsz);
pDC->EndPath();
pDC->SelectClipPath(RGN_DIFF);
nStrLen=lstrlen(lpsz);
GetTextExtentPoint32(pDC->GetSafeHdc(),lpsz, nStrLen, &sz);
for (int i = nYStart + 1; i < (nYStart + sz.cy); i += 3)
{
pDC->MoveTo( nXStart, i);
pDC->LineTo(nXStart + sz.cx, i);
}
for (i = nXStart + 1; i < (nXStart + sz.cx); i += 3)
{
pDC->MoveTo(i, nYStart);
pDC->LineTo(i, nYStart + sz.cy);
}
pDC->SelectObject(pOldFont);
}
/////////////////////////////////////////////////////////////////////////////
// CExampleView diagnostics
#ifdef _DEBUG
void CExampleView::AssertValid() const
{
CView::AssertValid();
}
void CExampleView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CExampleDoc* CExampleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExampleDoc)));
return (CExampleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExampleView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -