码迷,mamicode.com
首页 > 编程语言 > 详细

再探MFC(五)状态栏

时间:2015-04-01 17:48:52      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:mfc   对话框   vc++   

创建和初始化状态栏

step1

对话框添加变量

// 状态栏对象

CStatusBarm_wndStatusBar;

 

step2

OnInitDialog调用

 

//创建和初始化状态栏

BOOLCLBDKFODlg::CreateStatusBar()

{

 

    static UINT nIndicators[] = {

        ID_CALL_STATUS

    };

 

    if (!m_wndStatusBar.Create (this))

        return FALSE;

 

    m_wndStatusBar.SetIndicators (nIndicators,1);

 

CRectrect;

GetClientRect(&rect);

m_wndStatusBar.SetPaneInfo(0,ID_CALL_STATUS,SBPS_NORMAL,rect.Width());

 

//m_wndStatusBar.GetStatusBarCtrl().SetBkColor(RGB(180,180,180));

RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,ID_CALL_STATUS);

    return TRUE;

}

 

注意在资源文件中定义ID_CALL_STATUS.

 

更新状态栏文本

m_wndStatusBar.SetPaneText(0,"空闲");

 

 

参考资料

CStatusBarin CDialog,  SetPaneText and CTime,GetCurrentTime with VC++ Sample


To create a status bar, follow these steps:

  1. Construct the CStatusBar object.
  1. Call the Create (or CreateEx) function to create the status-bar window and attach it to the CStatusBar object.
  1. Call SetIndicators to associate a string ID with each indicator.

There are three ways to update the text in a status-bar pane:

  1. Call CWnd::SetWindowText to update the text in pane 0 only.
  1. Call CCmdUI::SetText in the status bar‘s ON_UPDATE_COMMAND_UI handler.
  1. Call SetPaneText to update the text for any pane.

 

源文档 <https://msdn.microsoft.com/en-us/library/fha3tfk7.aspx>


再探MFC(五)状态栏

标签:mfc   对话框   vc++   

原文地址:http://blog.csdn.net/soliddream66/article/details/44808423

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!