⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.cpp

📁 C++编程实践与技巧一书各章节的源码
💻 CPP
字号:
//类实现文件
//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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -