Link to home
Start Free TrialLog in
Avatar of pcssecure
pcssecureFlag for Hong Kong

asked on

Disable Toolbar.

I am working with the document view architecture's tool bars. How can I disable (gray-out) all the buttons in a tool bar? The tool bar is a CToolBar MFC object.

Thanks.
Avatar of vijay_visana
vijay_visana

Change the code in your mainframe.cpp as follow
//WS_DISABLED will disable your toolbar

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |WS_DISABLED| CBRS_TOP
            | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
            !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))


use of ON_UPDATE_COMMAND_UI  wil not only disable toolbar but will grayed particular item also.
Avatar of pcssecure

ASKER

Can you show me how to use
ON_UPDATE_COMMAND_UI ? Thanks.
I tried to use CWnd.EnableWindow(0). The toolbar is disabled but not grayed.
ASKER CERTIFIED SOLUTION
Avatar of vijay_visana
vijay_visana

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial