VC基于对话框使用状态栏方式(state bar)
2013-12-29 16:18
239 查看
在类C***Dlg的定义中声明BOOL CreateStateBar();函数。
以及 CStatusBarCtrl m_status_bar;//状态栏变量
函数实现方式如下:
BOOL C***Dlg::CreateStateBar()
{
int nTotWide;
// total width of status bar
CRect rect;
this->GetWindowRect(&rect);
rect.top = rect.bottom- 25;
BOOL m_bRvStatOk;
m_bRvStatOk = m_status_bar.Create(WS_CHILD|WS_VISIBLE ,rect,this,
IDC_STATUSBAR);
//注意:IDC_STATUSBAR为自己在Resource.h文件中define的值。大小根据实际情况。主要是资源编辑器识别。程序运行后以句柄为主要引导方式。
//如 #define IDC_STATUSBAR 1101
if (m_bRvStatOk == NULL)
{
AfxMessageBox ("Status Bar not created!", NULL, MB_OK );
}
//
//
get size of window, use to configure the status
// bar with four separate parts
//
CRect rWin;
this->GetWindowRect(&rWin);
nTotWide = rWin.right-rWin.left;
//
// Make each part 1/4 of the total width of the window.
//
int m_Widths[4];
m_Widths[0] = nTotWide / 4;
m_Widths[1] = nTotWide / 2;
m_Widths[2] = nTotWide - m_Widths[0];
m_Widths[3] = -1;
m_status_bar.SetMinHeight(25);
m_status_bar.SetParts( 4, m_Widths);
m_status_bar.SetText("BAMAC高稳型加热电源上位机软件",0,0);//后面几个状态Panel以此类推。比如加载进时间等。
m_status_bar.ShowWindow(SW_SHOW);
return TRUE;
}
在C***Dlg::OnInitDialog()中调入CreateStateBar()即可创建状态栏。
以及 CStatusBarCtrl m_status_bar;//状态栏变量
函数实现方式如下:
BOOL C***Dlg::CreateStateBar()
{
int nTotWide;
// total width of status bar
CRect rect;
this->GetWindowRect(&rect);
rect.top = rect.bottom- 25;
BOOL m_bRvStatOk;
m_bRvStatOk = m_status_bar.Create(WS_CHILD|WS_VISIBLE ,rect,this,
IDC_STATUSBAR);
//注意:IDC_STATUSBAR为自己在Resource.h文件中define的值。大小根据实际情况。主要是资源编辑器识别。程序运行后以句柄为主要引导方式。
//如 #define IDC_STATUSBAR 1101
if (m_bRvStatOk == NULL)
{
AfxMessageBox ("Status Bar not created!", NULL, MB_OK );
}
//
//
get size of window, use to configure the status
// bar with four separate parts
//
CRect rWin;
this->GetWindowRect(&rWin);
nTotWide = rWin.right-rWin.left;
//
// Make each part 1/4 of the total width of the window.
//
int m_Widths[4];
m_Widths[0] = nTotWide / 4;
m_Widths[1] = nTotWide / 2;
m_Widths[2] = nTotWide - m_Widths[0];
m_Widths[3] = -1;
m_status_bar.SetMinHeight(25);
m_status_bar.SetParts( 4, m_Widths);
m_status_bar.SetText("BAMAC高稳型加热电源上位机软件",0,0);//后面几个状态Panel以此类推。比如加载进时间等。
m_status_bar.ShowWindow(SW_SHOW);
return TRUE;
}
在C***Dlg::OnInitDialog()中调入CreateStateBar()即可创建状态栏。
相关文章推荐
- VC对话框使用OnEraseBkgnd函数位图背景并透明
- 在VC中如何使用对话框让用户选择自己保存文件的路径
- 如何使用VC对话框的句柄
- VC里基于对话框的程序屏蔽回车键自动退出程序
- 使用基于Android网络通信的OkHttp库实现Get和Post方式简单操作服务器JSON格式数据
- c# 引用 MySQL使用基于Parameter方式代码,总是提示:“Column '列名' cannot be null”
- 在MFC对话框中使用CChart--基于串口的温度采集
- VC中快捷方式的使用和原理
- C# / VB / LabView /VC 上位机使用OPC方式与PLC进行通信的教程
- VC对话框添加状态栏
- 程序启动时,隐藏对话框的方法(基于vc的对话框工程)
- 工厂模式实现方式、使用场景(包括基于反射的简单工厂模式)
- 7.11.2: 基于XML Schema的简化配置方式---使用util Schema
- VC++对话框中添加状态栏的方法
- MFC学习笔记——状态栏(基于对话框的MFC程序)
- WPF中使用文件浏览对话框的几种方式
- VC对话框程序如何使用chtmlview
- 基于对话框的MFC程序实现RTL风格的一种方式
- VC++对话框中加状态栏
- VC里基于对话框的程序屏蔽回车键自动退出程序