Microsoft KB Archive/315603

= HOW TO: Create a Class Derived from CControlBar and Its SubClasses in Visual C++ 6.0 =

PSS ID Number: 315603

Article Last Modified on 10/24/2003

-

The information in this article applies to:


 * Microsoft Visual C++ Standard Edition, version 6.0
 * Microsoft Visual C++, 32-bit Enterprise Edition 6.0

-



This article was previously published under Q315603





IN THIS TASK

 * SUMMARY
 * ** Requirements
 * Generating a Class That Is Based on CWnd
 * Modifying the Class Source



SUMMARY
In Microsoft Visual C++ 6.0, ClassWizard does not list CControlBar or any of its subclasses (CDialogBar, COleResizeBar, CStatusBar, CToolBar, and CReBar) in the Base class drop-down list box. This article shows you how to create a class derived from CControlBar and from its subclasses by using ClassWizard.

back to the top

Requirements

 * You must know Visual C++ 6.0 and the MFC framework classes.

back to the top

Generating a Class That Is Based on CWnd
To create a class derived from CControlBar, select generic CWnd as the base class, and then modify the files that are generated by ClassWizard.

For example, suppose you want to create a class called CMyBar that is derived from CReBar in an existing project. The following instructions assume that you have started Visual C++ 6.0 and that you have an MFC-based project open.
 * 1) Click New Class on the Insert menu.
 * 2) Type the class name CMyBar in the Name field of the dialog box.
 * 3) Click generic CWnd in the Base class field of the dialog box.
 * 4) Click OK.
 * 5) If the Workspace window is not visible, click Workspace on the View menu.
 * 6) At the bottom of the Workspace window, click the FileView tab.
 * 7) In the Workspace window, expand the Source Files folder and the Header Files folder. Make sure that the files named MyBar.cpp and MyBar.h have been generated.

back to the top

Modifying the Class Source
You must modify the code that is generated for the derived class because ClassWizard has created a class derived from CWnd and not from CReBar. You must change the second parameter of the BEGIN_MESSAGE_MAP macro that is added to the implementation of the class from CWnd to CReBar. This parameter specifies the immediate base class of the derived class.   Edit the file MyBar.cpp, and then change the message map declaration as follows: BEGIN_MESSAGE_MAP(CMyBar, CReBar)   Edit MyBar.h. Change the derived class definition so that it specifies CReBar as the base class, as follows: class CMyBar : public CReBar 

back to the top

Keywords: kbhowto kbHOWTOmaster KB315603

Technology: kbAudDeveloper kbVC32bitSearch kbVC600 kbVCsearch

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.