关于CControlBar和类向导使用 的问题!!急!!

xiaoyao19811201 2005-07-14 05:35:43
首先阐述一下情况:我在新建类的时候 Class type选择了Generic Class,
发现这样建出来的类,在“类视图”上用鼠标在右击该类的时候没有像其他
从Class type为MFC Class中继承下来的类一样有
Add Virtual Funtion..和Add windows message handle..这两项!!

并且这样的类在Class Wizard中也看不到

但是现在CControlBar是MFC中的类啊,我想让Class Wizard生成从
CControlBar派生出来的类,请问怎么实现???
...全文
117 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cdeee 2005-07-15
不要选 Generic Class 项,因为 VC 向导生成的类会在原文件中加入一些专门为向导准备的信息代码,选择 Generic Class 项后因为缺少这些信息,就会出现你说的这些现象。
回复
mintwlf 2005-07-15
通常类向导不让你直接派生的类是一些与其它类结合很紧密不容易派生的类,例如CControlBar,CDockBar。他们都是紧密相连的,简单的派生起不了作用。
回复
bager 2005-07-15
HOW TO: Create a Class Derived from CControlBar and Its SubClasses in Visual C++ 6.0

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.
Click New Class on the Insert menu.
Type the class name CMyBar in the Name field of the dialog box.
Click generic CWnd in the Base class field of the dialog box.
Click OK.
If the Workspace window is not visible, click Workspace on the View menu.
At the bottom of the Workspace window, click the FileView tab.
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

回复
发帖
界面
创建于2007-09-28

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2005-07-14 05:35
社区公告
暂无公告