Solved

How to access toolbar buttons from View class??

Posted on 2001-06-22
8
320 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, I have typed it wrong

'CTollBarCtrl&' instead of 'CToolBarCtrl*'
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Author Comment

by:techpage
Comment Utility
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
Comment Utility
CToolBarCtrl& pCtrl = pFrame->GetToolBarCtrl();
0
 
LVL 3

Author Comment

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

what does this mean??
0
 
LVL 2

Expert Comment

by:Chandra V
Comment Utility
Hai techpage,

Here is another simple method.

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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…

763 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

9 Experts available now in Live!

Get 1:1 Help Now