您的位置:首页 > 其它

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

2014-07-25 17:08 465 查看
当前我使用到的有效的方式是:

通过发消息的方式

 

禁用某个Toolbar中的按钮,例如ID为 IDC_BUTTON_ADD,Toolbar对像为m_wndToolBar,设置fsState为TBSTATE_INDETERMINATE

TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_STATE;
<span style="color:#000099;"><strong>tbinfo.fsState = TBSTATE_INDETERMINATE;
</strong></span> ::SendMessage(<strong><span style="color:#000099;">m_wndToolBar.GetSafeHwnd()</span></strong>, TB_SETBUTTONINFO,<strong><span style="color:#000099;">(WPARAM)IDC_BUTTON_ADD</span></strong>,(LPARAM)&tbinfo);


启用某个Toolar按钮,设置fsState为TBSTATE_ENABLED 

TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_STATE;
<span style="color:#000099;"><strong>tbinfo.fsState = TBSTATE_ENABLED;
</strong></span> ::SendMessage(<strong><span style="color:#000099;">m_wndToolBar.GetSafeHwnd()</span></strong>, TB_SETBUTTONINFO,<strong><span style="color:#000099;">(WPARAM)IDC_BUTTON_ADD</span></strong>,(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: 春夜喜雨 http://blog.csdn.net/chunyexiyu  转载请标明来源 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: