//---------------------------
//------本程序主要是在对话框中增加状态栏,自己绘制,主要有开始就可以显示数据
//------还可以当移动到一个控件上面,也可以在状态栏中显示数据,变化
//---------使用button 可以在程序中动态改变状态栏的中的信息
//------------本陈不都写在---- ****dlg.cpp 文件里面,不需要其他的
//---------2005年1月6日----9:49:00----made in haerbin of china
//-----------------刘莉莉 or liulili email: liulili995@163.com
//-----------------------------------------------------------------------------------------
//----------------------start---------****dlg.h file
public:
int count; //在button 点击以后,使用count传递变量,使得状态栏文字发生变化
cstatusbar m_status; //申明两个变量 状态栏
//----------------------end------------****dlg.h file
//
//
//-----------------------start----------****dlg.cpp file
begin_message_map(caboutdlg, cdialog)
//{{afx_msg_map(caboutdlg)
// no message handlers
//}}afx_msg_map
end_message_map()
//-----------my code--------------------------
//----for statusbar 下面的小格格个数----------
static uint status_id[]=
{
//-------设置5个小格格
id_separator,
id_separator, //可以多个
id_indicator_caps, //可以没有
id_indicator_num, //
id_indicator_scrl //
};
//------------------------------------
/////////////////////////////////////////////////////////////////////////////
// cmydlg dialog
//-----------------------------------
bool cmydlg::oninitdialog()
{
cdialog::oninitdialog();
// add "about..." menu item to system menu.
this->count =0;
// idm_aboutbox must be in the system command range.
assert((idm_aboutbox & 0xfff0) == idm_aboutbox);
assert(idm_aboutbox < 0xf000);
cmenu* psysmenu = getsystemmenu(false);
if (psysmenu != null)
{
cstring straboutmenu;
straboutmenu.loadstring(ids_aboutbox);
if (!straboutmenu.isempty())
{
psysmenu->appendmenu(mf_separator);
psysmenu->appendmenu(mf_string, idm_aboutbox, straboutmenu);
}
}
// set the icon for this dialog. the framework does this automatically
// when the application's main window is not a dialog
seticon(m_hicon, true); // set big icon
seticon(m_hicon, false); // set small icon
// todo: add extra initialization here
//-------------my code----------------------
//-----------初始化 状态栏 -----------------
if(!this->m_status.create(this)||!this->m_status.setindicators(status_id,sizeof(status_id)/sizeof(uint)))
{
return -1;
}
//-----------设置 状态兰的大小 和显示的文字-----------
uint nid; //控制状态栏里面的小格格
//-----------设置 小格格的具体信息
//--------------第一个格格,100,大小,样式
m_status.setpaneinfo(0,nid,sbps_stretch,100);
m_status.setpanetext(0,"hello!,welcome");
//--------------第二个格格,100,大小,样式
m_status.setpaneinfo(1,nid,sbps_stretch,100);
m_status.setpanetext(1,"a gril");
m_status.setpaneinfo(2,nid,sbps_stretch,100);
m_status.setpanetext(2,"this is chinese");
m_status.setpaneinfo(3,nid,sbps_stretch,100);
m_status.setpanetext(3,"1000");
//----------------让这个状态栏最终显示在对话框中-------------
repositionbars(afx_idw_controlbar_first,afx_idw_controlbar_last,0);
//-------------------------------------------
return true; // return true unless you set the focus to a control
}
//-------------------------------
bool cmydlg::onsetcursor(cwnd* pwnd, uint nhittest, uint message)
{
// todo: add your message handler code here and/or call default
//-------------my code---------------------
//-----------让我的鼠标移动到控件上面,就有相应的提示和变化
switch(message)
{
case wm_mousemove:
{
if(pwnd!=this)
{
switch(pwnd->getdlgctrlid())
{
case idc_edit1:
{
m_status.setpanetext(0,"编辑框");
break;
}
case idc_combo1:
{
{
m_status.setpanetext(0,"组合框");
break;
}
}