VC基于对话框使用状态栏方式(state bar)

在类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()即可创建状态栏。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值