Solved

How to access toolbar buttons from View class??

Posted on 2001-06-22
8
353 Views
Last Modified: 2013-11-20
The title is the question... how to access toolbar buttons from the View class??? can I just simply take a reference to my main frame class and make calls from that??
0
Comment
Question by:techpage
  • 4
  • 4
8 Comments
 
LVL 3

Author Comment

by:techpage
ID: 6220808
ps: I need to gain access to the toolbar buttons in order to change its checke/uncheck and enable/disable states...
0
 
LVL 2

Accepted Solution

by:
Chandra V earned 30 total points
ID: 6221137
Add a member function to the 'CMainFrame' class as shown below:

CToolBarCtrl& GetToolBarCtrl(){ return m_wndToolBar.GetToolBarCtrl();};

Use this in your view class by using the following(->include the 'MainFrm.h' file)

CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
CToolBarCtrl* pCtrl = pFrame->GetToolBarCtrl();

No you can do what ever you want to do with the toolbar by using the functions like 'CheckButton', 'PressButton', 'EnableButton' etc...
0
 
LVL 3

Author Comment

by:techpage
ID: 6221163
Hello, I've tried what you proposed...

but there is one error:

error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CToolBarCtrl' (or there is no acceptable conversion)

I don't know how to solve that...
0
Independent Software Vendors: 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!

 
LVL 2

Expert Comment

by:Chandra V
ID: 6221170
Sorry, I have typed it wrong

'CTollBarCtrl&' instead of 'CToolBarCtrl*'
0
 
LVL 3

Author Comment

by:techpage
ID: 6221171
Hello, I've tried what you proposed...

but there is one error:

error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CToolBarCtrl' (or there is no acceptable conversion)

I don't know how to solve that...
0
 
LVL 2

Expert Comment

by:Chandra V
ID: 6221172
CToolBarCtrl& pCtrl = pFrame->GetToolBarCtrl();
0
 
LVL 3

Author Comment

by:techpage
ID: 6221175
error C2758: 'pTBCtrl' : must be initialized in constructor base/member initializer list

what does this mean??
0
 
LVL 2

Expert Comment

by:Chandra V
ID: 6223845
Hai techpage,

Here is another simple method.

CToolBar * pToolBar = (CToolBar* ) AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 82
sumDigits challenge 9 171
fizzArray  challenge 1 107
pre4 challenge 19 110
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

685 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