Solved

Disable Toolbar.

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 122
Perl Awk Need Help 3 95
FizzBuzz challenge 9 73
scoreUp challenge 14 48
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now