在对话框中使用工具条
http://www.vchelp.net/source/dlgtoolbar.zip
肯定好使

解决方案 »

  1.   

    emmai(WaTaXiWaWaTaXi) :
      能不能把工具栏放在对话框中间(窗口正中间)?
      

  2.   

    以emmai提供的例子为例,只要在两次RopositionBar之后,调用下面这一句:
    m_wndToolBar.MoveWindow(CRect(10,67,392,100));
    就可以让ToolBar挪窝了。
      

  3.   

    我的这种方法比较直观,主要是定位快速,准确,充分利用可视化编程能力
    你的将工具栏置于中间的问题已解决,将下面的代码添加后,就会出现工具条出现在对话框中间的效果
    IDC_TOOLBAR_BASE是一个被放置在对话框中央的静态控件(做成边框,并设置属性为隐藏),m_toolbarCtrl为成员变量CToolBarCtrl
    BOOL CAboutDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    ////////////////
    TBBUTTON btn[2];                     btn[0].iBitmap = 0 ; 
    btn[0].idCommand = 333; 
    btn[0].fsState = TBSTATE_ENABLED  ; 
    btn[0].fsStyle = TBSTYLE_BUTTON  ; 
    btn[0].dwData = 0 ; 
    btn[0].iString = 0; 

    btn[1].iBitmap = 1 ; 
    btn[1].idCommand = 334 ; 
    btn[1].fsState = TBSTATE_ENABLED  ; 
    btn[1].fsStyle = TBSTYLE_BUTTON ; 
    btn[1].dwData = 0 ; 
    btn[1].iString = 1; 

    // Create the ToolBar 

    // If you want to position the toolbar at the top  use the CCS_TOP option. 
    m_toolbarCtrl.Create(TBSTYLE_TOOLTIPS |WS_CHILD | WS_VISIBLE | CCS_TOP | CCS_NODIVIDER, 
    CRect(0,0,0,0),
    GetDlgItem( IDC_TOOLBAR_BASE ),

    ); 

    // Add the number of buttons to be added to the Toobar Control 
    m_toolbarCtrl.AddButtons(2, btn); 

    // Select the Bitmap to be displayed 
    m_toolbarCtrl.AddBitmap(1, IDR_TOOLBAR2); 

    // Set the button size and the Image Size 

    CSize sz_btn(32,32); 
    m_toolbarCtrl.SetButtonSize(sz_btn); 

    CSize sz_img(32,32); 
    m_toolbarCtrl.SetBitmapSize(sz_img); 

    // Call Autosize to set the button and bitmap size 
    m_toolbarCtrl.AutoSize();  return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
    }
      

  4.   

    补充一下IDR_TOOLBAR2,是一个位图资源,64X32