📄 hellomfcview.cpp
字号:
// HelloMFCView.cpp : implementation of the CHelloMFCView class
//
#include "stdafx.h"
#include "HelloMFC.h"
#include "HelloMFCDoc.h"
#include "HelloMFCView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView
IMPLEMENT_DYNCREATE(CHelloMFCView, CView)
BEGIN_MESSAGE_MAP(CHelloMFCView, CView)
//{{AFX_MSG_MAP(CHelloMFCView)
ON_WM_PAINT()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView construction/destruction
CHelloMFCView::CHelloMFCView()
{
// TODO: add construction code here
}
CHelloMFCView::~CHelloMFCView()
{
}
BOOL CHelloMFCView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView drawing
void CHelloMFCView::OnDraw(CDC* pDC)
{
CHelloMFCDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView printing
BOOL CHelloMFCView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CHelloMFCView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CHelloMFCView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView diagnostics
#ifdef _DEBUG
void CHelloMFCView::AssertValid() const
{
CView::AssertValid();
}
void CHelloMFCView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CHelloMFCDoc* CHelloMFCView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHelloMFCDoc)));
return (CHelloMFCDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CHelloMFCView message handlers
void CHelloMFCView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(rect);
dc.SetTextAlign(TA_BOTTOM|TA_CENTER);
::LineDDA ( 0, 0, rect.right-50, rect.bottom, (LINEDDAPROC) ShowText,
(LPARAM)(LPVOID)&dc); // 触发ShowText()函数
// Do not call CView::OnPaint() for painting messages
}
VOID CALLBACK CHelloMFCView::ShowText(int x, int y, LPARAM lpdc)
{
char szText[]="Hello MFC !";
((CDC*)lpdc)->TextOut(x, y, szText, sizeof(szText)-1);
::Sleep(1); // 延迟1毫秒
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -