📄 11view.cpp
字号:
// 11View.cpp : implementation of the CMy11View class
//
#include "stdafx.h"
#include "11.h"
#include "11Doc.h"
#include "11View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy11View
IMPLEMENT_DYNCREATE(CMy11View, CView)
BEGIN_MESSAGE_MAP(CMy11View, CView)
//{{AFX_MSG_MAP(CMy11View)
ON_WM_MOUSEMOVE()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMy11View construction/destruction
CMy11View::CMy11View()
{
// TODO: add construction code here
}
CMy11View::~CMy11View()
{
}
BOOL CMy11View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMy11View drawing
void CMy11View::OnDraw(CDC* pDC)
{
CMy11Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect rClient;
CClientDC dc(this);
GetClientRect(rClient);
dc.FillSolidRect(&rClient,RGB(225,0,225));//设置背景颜色紫
pDC->SetTextColor(RGB(225,225,0));//设置字体颜色黄
pDC->SetBkColor(RGB(0,225,0));// 设置字体背景浅绿
pDC->TextOut(50,10,"这是一个VC++程序,实现的功能是:在状态栏显示当前时间,和鼠标的坐标。");//输出位置
pDC->TextOut(20,30,"在文档中输出文字,背景,和字体填充部分的颜色。");
}
/////////////////////////////////////////////////////////////////////////////
// CMy11View printing
BOOL CMy11View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMy11View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMy11View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMy11View diagnostics
#ifdef _DEBUG
void CMy11View::AssertValid() const
{
CView::AssertValid();
}
void CMy11View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMy11Doc* CMy11View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy11Doc)));
return (CMy11Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy11View message handlers
void CMy11View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("%d,%d",point.x,point.y);
((CStatusBar*)AfxGetMainWnd()->GetDlgItem(AFX_IDW_STATUS_BAR))->SetPaneText(0,str,true);
// 在状态栏显示坐标
CView::OnMouseMove(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -