当前我使用到的有效的方式是:
通过发消息的方式
禁用某个Toolbar中的按钮,例如ID为 IDC_BUTTON_ADD,Toolbar对像为m_wndToolBar,设置fsState为TBSTATE_INDETERMINATE
TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_STATE;
tbinfo.fsState = TBSTATE_INDETERMINATE;
::SendMessage(m_wndToolBar.GetSafeHwnd(), TB_SETBUTTONINFO, (WPARAM)IDC_BUTTON_ADD,(LPARAM)&tbinfo);
启用某个Toolar按钮,设置fsState为TBSTATE_ENABLED
TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_STATE;
tbinfo.fsState = TBSTATE_ENABLED;
::SendMessage(m_wndToolBar.GetSafeHwnd(), TB_SETBUTTONINFO, (WPARAM)IDC_BUTTON_ADD,(LPARAM)&tbinfo);
参见MSDN中,fsState的说明,还可以设置其它的状态,例如 HIDDEN
TBSTATE_CHECKED
The button has the TBSTYLE_CHECK style and is being clicked.
TBSTATE_ELLIPSES
Version 4.70. The button's text is cut off and an ellipsis is displayed.
TBSTATE_ENABLED
The button accepts user input. A button that doesn't have this state is grayed.
TBSTATE_HIDDEN
The button is not visible and cannot receive user input.
TBSTATE_INDETERMINATE
The button is grayed.
TBSTATE_MARKED
Version 4.71. The button is marked. The interpretation of a marked item is dependent upon the application.
TBSTATE_PRESSED
The button is being clicked.
TBSTATE_WRAP
The button is followed by a line break. The button must also have the TBSTATE_ENABLED state.
Owed by: 春夜喜雨 春夜喜雨-CSDN博客 转载请标明来源