CToolbar的按钮启用与禁用(enable/disable)

当前我使用到的有效的方式是:

通过发消息的方式

禁用某个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博客  转载请标明来源 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

春夜喜雨

稀罕你的喜欢!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值