Solved

Disable Toolbar.

Posted on 2004-04-27
5
875 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 90
has22 challenge 11 93
Path of Workbook 3 76
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 93
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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