MyStatusBar.cpp
上传用户:sdpcwz
上传日期:2009-12-14
资源大小:1237k
文件大小:1k
- // MyStatusBar.cpp: implementation of the CMyStatusBar class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "MyStatusBar.h"
- #include "Resource.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- IMPLEMENT_DYNCREATE(CMyStatusBar, CStatusBar)
- BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_UPDATE_COMMAND_UI(ID_INDICATOR_TIME, OnUpdateIndicatorTime)
- END_MESSAGE_MAP()
- CMyStatusBar::CMyStatusBar()
- : CStatusBar()
- , m_strClockFormat("%H:%M:%S")//格式化显示时间的格式
- {
- }
- CMyStatusBar::~CMyStatusBar() {
- }
- void CMyStatusBar::SetClockFormat(LPCTSTR strClockFormat)
- {
- m_strClockFormat = strClockFormat;
- }
- //创建窗口
- int CMyStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- CStatusBar::OnCreate(lpCreateStruct);
- // 保证每隔一秒时钟会更新,定义一个定时器
- SetTimer(ID_INDICATOR_TIME,1000,NULL);
- return 0;
- }
- //更新时间
- void CMyStatusBar::OnUpdateIndicatorTime(CCmdUI* pCmdUI) {
- pCmdUI->Enable(true);
- pCmdUI->SetText(CTime::GetCurrentTime().Format(m_strClockFormat));
- }
- //退出窗口
- void CMyStatusBar::OnDestroy()
- {
- //杀掉Timer
- KillTimer(ID_INDICATOR_TIME);
- CStatusBar::OnDestroy();
- }