我是新手,最近编成,需要实现工具条按钮的按下状态(凹下),我看toolbar类好象无此功能,而toolbarctrl类有,可是如何将二者连接起来呢?我的想法也许不对,请帮我实现此功能。谢谢!

解决方案 »

  1.   

    CToolBar  mytoolbar;
    CToolBarCtr youtoolbarctrl = mytoolbar.GetToolBarCtrl();  //好象是这个,你可以查查MSDN
      

  2.   

    添加相应的消息处理函数,如:
    afx_msg void YOUR_DEAL_FUNCTION(CCmdUI* pCmdUI);
    ON_UPDATE_COMMAND_UI(ID_YOUR_BUTTON, YOUR_DEAL_FUNCTION)
    void YOUR_CLASS::YOUR_DEAL_FUNCTION(CCmdUI* pCmdUI) 
    {
    pCmdUI->SetCheck(TRUE/FALSE);////TRUE 为按下状态,FALSE相反!
            ///////// 也可以就这个函数pCmdUI->SetRadio(TRUE/FALSE);

    }
      

  3.   

    取Toolbar窗口句柄hwndToolbar
    SendMessage( hwndToolbar, TB_PRESSBUTTON , (WPARAM)idButton, (LPARAM) MAKELONG(fPress, 0) ); 
    idButton: 
       Command identifier of the button to press or release
    fPress :
       Press flag. If this parameter is TRUE, the button is pressed. If it is FALSE, the button is released. 
      

  4.   

    void CDialogMenuToolBarDlg::OnUpdateDrawFilledRect(CCmdUI *pCmdUI)
    {
    pCmdUI->SetCheck(m_bFilledRect);
    }
    ---------------------
    晕倒,使用 ON_UPDATE_COMMAND_UI()消息呀!
    在mfc中所有的界面的更新都是这样做的!
    但是在dialog中使用时应做一些额外的处理
      

  5.   

    使用clwfe(人刀贝)的方法或使用如下方法: CToolBar  m_wndToolBar;
    CToolBarCtr wndToolbarCtrl= wndToolBar.GetToolBarCtrl();  BOOL CToolBarCtrl::CheckButton( int nID, BOOL bCheck = TRUE );
      

  6.   

    CToolBar  yourtoolbar;
    CToolBarCtr* yourtoolbarctrl = yourtoolbar.GetToolBarCtrl();  
    yourtoolbarctrl->CheckButton( int nID, BOOL bCheck = TRUE );