注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

指南针的天空

你永远也看不到我最寂寞时候的样子,因为只有你不在我身边的时候,我才最寂寞。

 
 
 

日志

 
 

VC++对话框中添加状态栏的方法  

2008-04-02 22:27:22|  分类: Visual C++ |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

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));//为第二个分栏中加的图标

方法二:
1.添加成员变量CStatusBar m_wndStatusBar;
2.在OnInitDialog()中加入:
                   static UINT indicators[] =
                   {
                                 ID_SEPARATOR,                                   // status line indicator
                                 ID_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);

  评论这张
 
阅读(162)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017