Solved

Set state of toolbar button?

Posted on 2001-08-17
1
689 Views
Last Modified: 2013-11-20
Hi and thank for your time to read my question,

I am using VC6, I have a workspace: CMyApp, and have a toolbar in CMainFrame. I want to set the button of this toolbar to HIDDEN from CMyAppView class, or CMyAppDoc class, but I don't know how the way.

I tried declare a static CToolbar's variable at CMainForm, and in CMyAppView, I call this static variable for my purpose, but not successful.

Pls help me.
Best regards and thanks in advance.
0
Comment
Question by:vinhdh
[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
1 Comment
 

Accepted Solution

by:
resham earned 50 total points
ID: 6399781
Hi,

You can access MainFrame's members in ur application by calling AfxGetMainWnd().

Here is the sample code
In view class

CMainFrame *pMainFrm = (CMainFrame*) AfxGetMainWnd();
CToolBar& toolBar = pMainFrm->GetToolBar();
CToolBarCtrl& tbCtrl = toolBar.GetToolBarCtrl();

//To hide the  button
tbCtrl.HideButton(ID_FILE_PRINT, FALSE);

And in MainFrame Class
CToolBar& CMainFrame::GetToolBar()
{
     return m_wndToolBar;
}


Hope this will help.

Resham

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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. …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

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