像CDialogBar这种MFC提供的类要继承的话是不是只能手工加代码,而不能靠在classwizard里选择base class这种方法?

shofar 2002-09-07 09:32:39
像CDialogBar这种MFC提供的类要继承的话是不是只能手工加代码,而不能靠在classwizard里选择base class这种方法?
...全文
48 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
polosheng 2002-09-08
  • 打赏
  • 举报
回复
你可以先继承cdialog,做完了你的wizard工作后,将cdialog改成cdialogbar
注意,构造函数是传给cdialog是没有参数的.
我试过,还是比较方便的.呵呵
darkxiao 2002-09-08
  • 打赏
  • 举报
回复
我采用的方法是基类选择CWnd,然后改成CDialogBar就行了。
shofar 2002-09-08
  • 打赏
  • 举报
回复
那这样可真麻烦啊。
alidiedie 2002-09-08
  • 打赏
  • 举报
回复
这是我在别的帖子里的解答,转到这:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q185672&
我摘要了九步列出来(例子就看上面的url吧)
1.Change the base class from CDialog to CDialogBar in the class declaration. Don't forget to also change the base class in BEGIN_MESSAGE_MAP in the .cpp file.
2.Change the constructor in both the .h and the .cpp files. Also make the change to the DoDataExchange(). Below are three items to change.
3.Remove "virtual BOOL OnInitDialog();" from the class header and add "afx_msg LONG OnInitDialog ( UINT, LONG );" in its place.
4.Add "ON_MESSAGE(WM_INITDIALOG, OnInitDialog );" to the message map in the .CPP implementation file
5.Make the OnInitDialog() conversion as the example(见例子)
6.Make sure the dialog box resource styles to the following:
Style: Child
Boarder: None
Visible: Unchecked
At this point, everything has been reconnected to make the transformation from a CDialog class to a CDialogBar class work correctly. Now, create and use it.
7.Add an instance of the derived CDialogBar to the CframeWnd-derived class (normally called CMainFrame).
8.Call the create method for the m_myDlgBar variable in the CFrameWnd::OnCreate() method
9.
Finally, you an support dynamic docking and resizing of the CDialogBar

其实这里涉及的一个问题就是如何从classwizzard列表里没有的基类派生新类.
通用的说明见下面的url:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q99161


shofar 2002-09-08
  • 打赏
  • 举报
回复
微软也真是的,这个难度又不高,干嘛做成这样,自已改还是挺麻烦的。
everandforever 2002-09-07
  • 打赏
  • 举报
回复
是!
shofar 2002-09-07
  • 打赏
  • 举报
回复
哪位高手能回答我一下?谢谢!

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧