📄 timeview.cpp
字号:
// TimeView.cpp : implementation of the CTimeView class
//
#include "stdafx.h"
#include "Time.h"
#include "TimeDoc.h"
#include "TimeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTimeView
IMPLEMENT_DYNCREATE(CTimeView, CView)
BEGIN_MESSAGE_MAP(CTimeView, CView)
//{{AFX_MSG_MAP(CTimeView)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_TIMER()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CTimeView construction/destruction
CTimeView::CTimeView()
{
// TODO: add construction code here
}
CTimeView::~CTimeView()
{
}
BOOL CTimeView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTimeView drawing
void CTimeView::OnDraw(CDC* pDC)
{
CTimeDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTimeView printing
BOOL CTimeView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTimeView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTimeView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTimeView diagnostics
#ifdef _DEBUG
void CTimeView::AssertValid() const
{
CView::AssertValid();
}
void CTimeView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTimeDoc* CTimeView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTimeDoc)));
return (CTimeDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTimeView message handlers
void CTimeView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_point=point;
SetTimer(1,2000,NULL); //1为定时器的一个编码,2000为2000毫秒
CView::OnLButtonDown(nFlags, point);
}
void CTimeView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
CView::OnRButtonDown(nFlags, point);
}
void CTimeView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
static x1 = m_point.x - 10; //静态变量初始化,只在第一次执行此函数时执行
static y1 = m_point.y - 10;
static x2 = m_point.x - 10;
static y2 = m_point.y - 10;
x1 -= 10;
y1 -= 10;
x2 += 10;
y2 += 10;
CClientDC dc(this);
dc.Ellipse(x1, y1, x2, y2);
CView::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -