在对话框的资源OnInitDialog函数中加入如下代码:
//m_Toolbar.ShowWindow(SW_HIDE);
//设置自己的工具栏
SetIcon(LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MAINFRAME)),TRUE);
//获取时间,显示在状态栏
CTime Time;
Time = CTime::GetCurrentTime();
CString Str = Time.Format("%Y-%m-%d");
//CString str;
//str.Format("%02d:%02d:%02d",Time.GetHour(),Time.GetMinute(),Time.GetSecond());
//SetDlgItemText(IDC_STATIC_TIME,str);
//加载资源图片
m_Imagelist.Create(32,32,ILC_COLOR24|ILC_MASK,1,1);
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_CLDJ));//车辆登记
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_ZXCL));//在修车辆
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_SHFW));//售后服务
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_CLJS));//车辆结算
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_KHCZ));//客户充值
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_ZBGJ));//账本工具
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_BBZX));//报表中心
m_Imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON_KQ));//考勤
//设置右工具栏中的7个按钮
UINT Array[8];
for(int i=0;i<8;i++)
{
//添加分隔符
//if (i == 3)
//{
// Array[i] = ID_SEPARATOR;
//}
//else
//{
//代表其中按钮的地址
Array[i]=9000+i;
//}
}
//创建工具栏
m_Toolbar.Create(this);
//设置按钮
m_Toolbar.SetButtons(Array,8);
//设置按钮图标文字
m_Toolbar.SetButtonText(0,"车辆登记");
m_Toolbar.SetButtonText(1,"在修车辆");
m_Toolbar.SetButtonText(2,"售后服务");
m_Toolbar.SetButtonText(3,"车辆结算");
m_Toolbar.SetButtonText(4,"客户充值");
m_Toolbar.SetButtonText(5,"账本工具");
m_Toolbar.SetButtonText(6,"报表中心");
m_Toolbar.SetButtonText(7,"考勤");
//设置按钮大小
m_Toolbar.GetToolBarCtrl().SetButtonWidth(60,120);
//将按钮和资源图标相关联
m_Toolbar.GetToolBarCtrl().SetImageList(&m_Imagelist);
m_Toolbar.SetSizes(CSize(70,60),CSize(28,40));
//激活鼠标提示功能
m_Toolbar.EnableToolTips(TRUE);
for(i=0;i<4;i++)
{
Array[i]=10000+1;
}
m_Statusbar.Create(this);
m_Statusbar.SetIndicators(Array,4);
for(int n=0;n<4;n++)
{
m_Statusbar.SetPaneInfo(n,Array[n],0,80);
}
m_Statusbar.SetPaneInfo(1,Array[1],0,200);
m_Statusbar.SetPaneInfo(3,Array[3],0,1500);
m_Statusbar.SetPaneText(3,"当前日期"+Str);
m_Statusbar.SetPaneText(0,"京通ERP系统");
//显示工具栏
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
运行即可