• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

Set state of toolbar button?

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
vinhdh
Asked:
vinhdh
1 Solution
 
reshamCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now