CToolbarCtrl & CToolbar

What is the difference between the abovementioned?
RodneyYeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

This is from online help for VC++

The CToolBar and CToolBarCtrl Classes

You manage your application's toolbars via class CToolBar. As of MFC version 4.0, CToolBar has been reimplemented to use the toolbar common control available under Windows 95 and Windows NT version 3.51 or later.

This reimplementation results in less MFC code for toolbars, because MFC makes use of operating system support. The reimplementation also improves capability. You can use CToolBar member functions to manipulate toolbars, or you can obtain a reference to the underlying CToolBarCtrl object and call its member functions for toolbar customization and additional functionality.

U can find more there.
Try it out.
0
RodneyYeoAuthor Commented:
I found out that you can obtain an instance of CToolBarCtrl using GetToolBarCtrl(). In the source code implementation for that it's

CToolBarCtrl& CToolBar::GetToolBarCtrl() const
{ return *(CToolBarCtrl*) this; }
It seems to be like CToolBarCtrl == CToolBar. Comments?

Let's say I create a new class called CABCBar and I want to create a corresponding Control for it..how can i go about doing it?
0
RodneyYeoAuthor Commented:
Adjusted points to 80
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Is that class is derived from CToolBar?, if yes then
CABCBar::GetToolBarCtrl() must give U the tool bar control.

Try it out.
0
RodneyYeoAuthor Commented:
Both classes will inherit from CWnd, something like CControlBar and CToolBar.
Any idea?
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

If U want to use those classes as CControlBar or CToolBar, Then derive them from CControlBar or CToolBar only and U can still access the functionalities of CWnd as it is the base class for CControlBar and CToolBar. If U have already derived them from CWnd, I think it is better to change that to CToolBar or CControlBar.(U can replace CWnd by CToolBar or CControlBar. But do it carefully, make sure to replace both in *.h and *.cpp file)

Try it out.
0
RodneyYeoAuthor Commented:
Thanks for your comment.For my case, I would like to create a new class say called CABCBar, how do I create a corresponding CABCBarCtrl, something like that relationship between CToolbar and CToolbarCtrl? It seems like CToolbar must have kept an instance of CToolbarCtrl to access its methods, I've check through the source code and I didn't find that in CToolbar...comments?
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Using class wizard create new class CABCBarCtrl, derive it from CToolBarCtrl class. And CABCBar is of CToolBar class. Say I have a object m_toolbar of CABCBar class. Then

m_toolbar.GetToolbarCtrl() must return the control handle and assign it to the instance of Ur CABCBarCtrl instead of CToolBarCtrl.

Then U will have the control rigth?.
Try it out.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RodneyYeoAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.