取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.
CToolBarCtr youtoolbarctrl = mytoolbar.GetToolBarCtrl(); //好象是这个,你可以查查MSDN
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);
}
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.
{
pCmdUI->SetCheck(m_bFilledRect);
}
---------------------
晕倒,使用 ON_UPDATE_COMMAND_UI()消息呀!
在mfc中所有的界面的更新都是这样做的!
但是在dialog中使用时应做一些额外的处理
CToolBarCtr wndToolbarCtrl= wndToolBar.GetToolBarCtrl(); BOOL CToolBarCtrl::CheckButton( int nID, BOOL bCheck = TRUE );
CToolBarCtr* yourtoolbarctrl = yourtoolbar.GetToolBarCtrl();
yourtoolbarctrl->CheckButton( int nID, BOOL bCheck = TRUE );