VC++之工具栏与状态栏之显示进度条
一、编程思路
二、创建新工程
三、添加字符串资源
四、添加函数
五、添加代码
      1、于CMainFrame”类之头文件内添加自定义消息
      2、于CMainFrame”类之头文件内添加变量、声明自定义消息的响应函数
      3、于CMainFrame”类内添加自定义消息到响应函数映射
statusbar是什么意思
      4、于CMainFrame”类内定义自定义消息的响应函数
      5、于CMainFrame”类的OnCreate()内添加初始化代码
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
  TRACE0("Failed to create toolbar\n");
  return -1;      // fail to create
}
if (!m_wndStatusBar.Create(this) ||
  !m_wndStatusBar.SetIndicators(indicators,
    sizeof(indicators)/sizeof(UINT)))
{
  TRACE0("Failed to create status bar\n");
  return -1;      // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
  PostMessage(USER_PROGRESS); //发送自定义消息
  SetTimer(1,1000,NULL);  //添加定时器
return 0;
}
      6、于CMainFrame”类内添加新增函数代码
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
static int number=0;
CString str;
m_progress.SetPos(number); //设定进度信息
number+=10;
  str.Format("%d",number);
m_wndStatusBar.SetPaneText(2,str); //显示进度信息
if(number>=100)number=0;
CFrameWnd::OnTimer(nIDEvent);
}

void CMainFrame::OnPaint()
{
CPaintDC dc(this); // device context for painting
  // TODO: Add your message handler code here
          CRect rect;
          m_wndStatusBar.GetItemRect(1,&rect);
          if(m_progress.m_hWnd)
          m_progress.MoveWindow(rect);//将进度栏移到新位置
/
/ Do not call CFrameWnd::OnPaint() for painting messages
}
六、编译
七、运行
八、函数说明
      1CStaticBar::GetItemRect函数声明
        void GetItemRect(int nIndex,LPRECT lpRect)const
        nIndex:状态栏窗格的索引
        lpRect:保持状态栏窗格位置的指针