CToolbarCtrl & CToolbar

What is the difference between the abovementioned?
RodneyYeoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Vinayak KumbarConnect With a Mentor Sr 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
 
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
RodneyYeoAuthor Commented:
Adjusted points to 80
0
 
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
 
RodneyYeoAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.