Solved

Disable Toolbar.

Posted on 2004-04-27
5
889 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:pcssecure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10926157
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))


0
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10926209
use of ON_UPDATE_COMMAND_UI  wil not only disable toolbar but will grayed particular item also.
0
 

Author Comment

by:pcssecure
ID: 10926221
Can you show me how to use
ON_UPDATE_COMMAND_UI ? Thanks.
0
 

Author Comment

by:pcssecure
ID: 10926238
I tried to use CWnd.EnableWindow(0). The toolbar is disabled but not grayed.
0
 
LVL 7

Accepted Solution

by:
vijay_visana earned 500 total points
ID: 10926365
IN mainframe.cpp

Add following entry in message map
      ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_NEW,ID_APP_ABOUT, OnUpdateToolbar)

here ID_FILE_NEW and ID_APP_ABOUT is range for my toolbar (created by class wizard ) . If you have different id range subsitute them here

//add following to mainframe.cpp
void CMainFrame::OnUpdateToolbar(CCmdUI *pCmdUI)
{
    pCmdUI->Enable (FALSE);//<<=== here you can take variable /class member
                                          //set it true anywhere and your toolbar will be enable set it false to make
                                         // make toolbar disable
}

//add following to header file for mainframe class


      //{{AFX_MSG(CMainFrame)
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
            // NOTE - the ClassWizard will add and remove member functions here.
      afx_msg void OnUpdateToolbar(CCmdUI *pCmdUI);     //add this line<<=========
            //    DO NOT EDIT what you see in these blocks of generated code!
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()

good luck
Vijay
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question