📄 useclockview.cpp
字号:
// UseClockView.cpp : CUseClockView 类的实现
//
#include "stdafx.h"
#include "UseClock.h"
#include "UseClockDoc.h"
#include "UseClockView.h"
#include "TimeremindDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CUseClockView
IMPLEMENT_DYNCREATE(CUseClockView, CFormView)
BEGIN_MESSAGE_MAP(CUseClockView, CFormView)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_VIEW_STARTTIMING, OnViewStarttiming)
ON_COMMAND(ID_VIEW_ENDTIMING, OnViewEndtiming)
ON_COMMAND(ID_VIEW_REMIND, OnViewRemind)
END_MESSAGE_MAP()
// CUseClockView 构造/销毁
CUseClockView::CUseClockView()
: CFormView(CUseClockView::IDD)
{
// TODO: 在此处添加构造代码
}
CUseClockView::~CUseClockView()
{
}
void CUseClockView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RICHTEXTCTRL, m_RichTextCtrl);
DDX_Control(pDX, IDC_CLOCKCTRL, m_ClockCtrl);
}
BOOL CUseClockView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CFormView::PreCreateWindow(cs);
}
void CUseClockView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
// CUseClockView 诊断
#ifdef _DEBUG
void CUseClockView::AssertValid() const
{
CFormView::AssertValid();
}
void CUseClockView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CUseClockDoc* CUseClockView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUseClockDoc)));
return (CUseClockDoc*)m_pDocument;
}
#endif //_DEBUG
// CUseClockView 消息处理程序
void CUseClockView::OnFileOpen()
{
// TODO: 在此添加命令处理程序代码
char FileName[128];
char str[128];
strcpy(str,"Rich Text Viewer");
CFileDialog dlg(TRUE,"rtf",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Microsoft Word Files (*.doc)|*.doc|Rich Text Files (*.rtf)|*.rtf|Text Files (*.txt)|*.txt|");
if(dlg.DoModal()==IDOK)
{
strcpy(FileName,(dlg.GetPathName()).GetBuffer(128));
m_RichTextCtrl.put_FileName(FileName);
m_RichTextCtrl.Refresh();
strcat(str,"--");
strcat(str,FileName);
SetWindowText(str);
}
}
void CUseClockView::OnViewStarttiming()
{
// TODO: 在此添加命令处理程序代码
m_ClockCtrl.StartTimeKeeper();
}
void CUseClockView::OnViewEndtiming()
{
// TODO: 在此添加命令处理程序代码
CString str;
str.Format("Time used:%d seconds",m_ClockCtrl.KillTimekeeper());
MessageBox(str);
}
void CUseClockView::OnViewRemind()
{
// TODO: 在此添加命令处理程序代码
CTimeremindDialog dlg;
if(dlg.DoModal()==IDOK)
{
short h=dlg.m_hour;
short m=dlg.m_minute;
short s=dlg.m_second;
m_ClockCtrl.SetActiveTime(h,m,s);
}
}
BEGIN_EVENTSINK_MAP(CUseClockView, CFormView)
ON_EVENT(CUseClockView, IDC_CLOCKCTRL, 1, ActiveWhenClockctrl, VTS_I2 VTS_I2 VTS_I2)
ON_EVENT(CUseClockView, IDC_CLOCKCTRL, DISPID_KEYPRESS, KeyPressClockctrl, VTS_PI2)
END_EVENTSINK_MAP()
void CUseClockView::ActiveWhenClockctrl(short hour, short min, short sec)
{
// TODO: 在此添加消息处理程序代码
CString str;
str.Format("you ought to do something at %d:%d:%d.",hour,min,sec);
MessageBox(str);
}
void CUseClockView::KeyPressClockctrl(short* KeyAscii)
{
// TODO: 在此添加消息处理程序代码
CString str;
str.Format("Key Code: %d",*KeyAscii);
MessageBox(str);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -