1. 程式人生 > >在狀態欄上顯示時間

在狀態欄上顯示時間

bsp ctime todo login gettext 程序代碼 cstring comm stat

// TODO: 在此添加消息處理程序代碼和/或調用默認值 //獲得當前的系統時間 CTime t=CTime::GetCurrentTime(); CClientDC dc(this); //格式可以參考MSDN中的strftime函數 CString str=_T("時間:")+ t.Format("%Y-%m-%d %H:%M:%S"); //設置一個CClientDC對象來獲取str的長度 CSize sz=dc.GetTextExtent(str); int index=0; //由ID號獲取索引序號 index=m_wndStatusBar.CommandToIndex(IDS_LOGIN); //設置狀態欄寬度 m_wndStatusBar.SetPaneInfo(index,IDS_LOGIN,SBPS_NORMAL,sz.cx); //設置要顯示的字符串 m_wndStatusBar.SetPaneText(index,str);


在狀態欄上顯示時間