📄 windowsview.cpp
字号:
// windowsView.cpp : implementation of the CWindowsView class
//
#include "stdafx.h"
#include "windows.h"
#include "windowsDoc.h"
#include "windowsView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWindowsView
IMPLEMENT_DYNCREATE(CWindowsView, CView)
BEGIN_MESSAGE_MAP(CWindowsView, CView)
//{{AFX_MSG_MAP(CWindowsView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CWindowsView construction/destruction
CWindowsView::CWindowsView()
{
// TODO: add construction code here
}
CWindowsView::~CWindowsView()
{
}
BOOL CWindowsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CWindowsView drawing
void CWindowsView::OnDraw(CDC* pDC)
{
CWindowsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
CPen* pOldPen = pDC->SelectObject(&penBlue);
// and a solid red brush
CBrush brushRed(RGB(255, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&brushRed);
// Find the midpoints of the top, right, left, and bottom
// of the client area. They will be the vertices of our polygon.
CPoint pts[10];
pts[0].x = 181; pts[0].y = 26;
pts[1].x = 143; pts[1].y = 133;
pts[2].x = 19; pts[2].y = 133;
pts[3].x = 119; pts[3].y = 199;
pts[4].x = 82; pts[4].y = 306;
pts[5].x = 181; pts[5].y = 242;
pts[6].x = 279; pts[6].y = 305;
pts[7].x = 242; pts[7].y = 199;
pts[8].x = 342; pts[8].y = 133;
pts[9].x = 218; pts[9].y = 133;
pDC->Polygon(pts, 10);
// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
/////////////////////////////////////////////////////////////////////////////
// CWindowsView printing
BOOL CWindowsView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CWindowsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CWindowsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CWindowsView diagnostics
#ifdef _DEBUG
void CWindowsView::AssertValid() const
{
CView::AssertValid();
}
void CWindowsView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CWindowsDoc* CWindowsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWindowsDoc)));
return (CWindowsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWindowsView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -