Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable Toolbar.

Posted on 2004-04-27
5
Medium Priority
?
910 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

636 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