Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

How to access toolbar buttons from View class??

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
techpage
Asked:
techpage
  • 4
  • 4
1 Solution
 
techpageAuthor Commented:
ps: I need to gain access to the toolbar buttons in order to change its checke/uncheck and enable/disable states...
0
 
Chandra VConsultantCommented:
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
 
techpageAuthor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
Chandra VConsultantCommented:
Sorry, I have typed it wrong

'CTollBarCtrl&' instead of 'CToolBarCtrl*'
0
 
techpageAuthor Commented:
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
 
Chandra VConsultantCommented:
CToolBarCtrl& pCtrl = pFrame->GetToolBarCtrl();
0
 
techpageAuthor Commented:
error C2758: 'pTBCtrl' : must be initialized in constructor base/member initializer list

what does this mean??
0
 
Chandra VConsultantCommented:
Hai techpage,

Here is another simple method.

CToolBar * pToolBar = (CToolBar* ) AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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