【MFC基础】15状态栏StatusBar

编程入门 行业动态 更新时间:2024-10-25 00:24:51

【MFC基础】15<a href=https://www.elefans.com/category/jswz/34/1763331.html style=状态栏StatusBar"/>

【MFC基础】15状态栏StatusBar

方法1

1.添加成员变量CStatusBarCtrl m_StatusBar;
2.在OnInitDialog()中加入:

m_StatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW, CRect(0,0,0,0), this, 0); int strPartDim[3]= {100, 200, -1}; //分割数量
m_StatusBar.SetParts(3, strPartDim);
//设置状态栏文本
m_StatusBar.SetText(“分栏一”, 0, 0);
m_StatusBar.SetText(“分栏二”, 1, 0);
m_StatusBar.SetText(“分栏三”, 2, 0);
//下面是在状态栏中加入图标
m_StatusBar.SetIcon(1, SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),
FALSE));//为第二个分栏中加的图标

方法2

1.添加成员变量CStatusBar m_wndStatusBar;
2.在OnInitDialog()中加入:

static UINT indicators[] =
{ID_SEPARATOR, // status line indicatorID_INDICATOR_CAPS, //CAP lock indicator.ID_INDICATOR_NUM, //NUM lock indicator.ID_INDICATOR_SCRL, //SCRL lock indicator.
};if (!m_wndStatusBar.Create(this) ||!m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT)))
{TRACE0(“Failed to create status barn”);return -1; // fail to create
}UINT nID; //控制状态栏里面的分栏
m_wndStatusBar.SetPaneInfo(0,nID,SBPS_STRETCH|SBPS_NOBORDERS,100); //返回值存nID中
m_wndStatusBar.SetPaneText(0,”就绪”);
m_wndStatusBar.SetPaneInfo(1,nID,SBPS_NORMAL,100);
m_wndStatusBar.SetPaneText(1,”大写”);
m_wndStatusBar.SetPaneInfo(2,nID,SBPS_POPOUT,100);
m_wndStatusBar.SetPaneText(2,”数字”);// SetPaneInfo()函数的第三个参数的可选项如下:
// The following indicator styles are supported:
// SBPS_NOBORDERS No 3-D border around the pane.
// SBPS_POPOUT Reverse border so that text “pops out.”
// SBPS_DISABLED Do not draw text.
// SBPS_STRETCH Stretch pane to fill unused space. Only one pane per status bar can have this style.
// SBPS_NORMAL No stretch, borders, or pop-out.//—————-让这个状态栏最终显示在对话框中————-
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);

更多推荐

【MFC基础】15状态栏StatusBar

本文发布于:2024-02-27 02:32:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1704873.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态栏   基础   MFC   StatusBar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!