您的位置:首页 > 编程语言

MFC状态栏的编程(以显示系统当前时间为例)

2011-05-15 21:41 405 查看
首先:在Resourse 选项卡上面的String Table 中添加:窗格如:IDS_TIMER 时钟

其次:在MainFrame APP 文件中加入标识
如:
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
// ID_INDICATOR_CAPS,
// ID_INDICATOR_NUM,
// ID_INDICATOR_SCRL,
IDS_TIMER,
};

再次:MainFrame::OnCreate()函数中添加如下代码:
CTime t=CTime::GetCurrentTime();
CString str=t.Format("%H : %M : %S ");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);

int index=0;
index=m_wndStatusBar.CommandToIndex(IDS_TIMER);
m_wndStatusBar.SetPaneInfo(index,IDS_TIMER,SBPS_NORMAL,sz.cx);
m_wndStatusBar.SetPaneText(index,str);

最后在OnTimer()函数中添加如下代码:

状态栏的编程
CTime t=CTime::GetCurrentTime();
CString str=t.Format("%H : %M : %S ");
CClientDC dc(this);
CSize sz=dc.GetTextExtent(str);
m_wndStatusBar.SetPaneInfo(1, IDS_TIMER, SBPS_NORMAL, sz.cx);
m_wndStatusBar.SetPaneText(1, str);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: