clock.cpp
来自「C++编程实践与技巧一书各章节的源码」· C++ 代码 · 共 56 行
CPP
56 行
//类实现文件
//clock.cpp:
//==============
#include "stdafx.h"
#include "clock.h"
#include "Resource.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CClockStatusBar, CStatusBar)
BEGIN_MESSAGE_MAP(CClockStatusBar, CStatusBar)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_UPDATE_COMMAND_UI(ID_INDICATOR_TIME, OnUpdateIndicatorTime)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CClockStatusBar::CClockStatusBar()
: CStatusBar()
, m_strClockFormat("%H:%M:%S")
{
}
CClockStatusBar::~CClockStatusBar() {
}
void CClockStatusBar::SetClockFormat(LPCTSTR strClockFormat) {
m_strClockFormat = strClockFormat;
}
int CClockStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct) {
// make sure time gets updated every second, even when idle
CStatusBar::OnCreate(lpCreateStruct);
SetTimer(ID_INDICATOR_TIME,1000,NULL);
return 0;
}
void CClockStatusBar::OnUpdateIndicatorTime(CCmdUI* pCmdUI) {
pCmdUI->Enable(true);
pCmdUI->SetText(CTime::GetCurrentTime().Format(m_strClockFormat));
}
void CClockStatusBar::OnDestroy() {
KillTimer(ID_INDICATOR_TIME);
// ProgressDestroy();
CStatusBar::OnDestroy();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?