重载cedit并在ceditview中使用它 [英] Overload cedit and use it in ceditview
问题描述
您好,
我在C ++中使用MFC在VS 7.1下有一个旧的SDI应用程序。
我想得到CEdit class添加一些功能(例如CEditEx)。
我没有找到如何在我的CEditView派生类中使用这个CEditEx类;它仅涉及CEdit功能。
提前感谢您的帮助(如果可能的话,还有一些关于CEdit和CEditView之间链接的其他说明),>
Eric
我尝试过:
我试图重载GetEditCtrl()。
引用:关于链接的说明CEdit和CEditView之间
CEditView
有点特别。虽然没有继承形式CEdit
,但它表现得像一个。请参阅 afxext.inl :
// CEditView
//注意:GetEditCtrl中的强制转换是丑陋的,但必须保留以保持兼容性。
// CEdit通过继承与CEditView无关,所以我们必须小心确保
// CEdit仍然是CEditView的二进制兼容子集。
_AFXEXT_INLINE CEdit& CEditView :: GetEditCtrl()const
{return *(CEdit *)this; }
解决方案是在CEditView
派生类中实现所需的功能。
如果你有扩展的CEdit
类的源代码,请将所需的代码部分复制到CEditView 基于code>的所有
CEdit
成员的类和前缀访问权限GetEditCtrl()
。
< br>
请参阅 CEditView类 [ ^ ],它显示了父类,因此您可以看到它继承的内容。 / BLOCKQUOTE>
Hello,
I have an old SDI application under VS 7.1 in C++ using MFC.
And I would like to derive CEdit class to add some features (e.g. CEditEx).
I did not find how to use this CEditEx class in my CEditView derived class; it refers to CEdit capabilities only.
Thank you in advance for your help (with, if possible, some additional explanation about link between CEdit and CEditView),
Eric
What I have tried:
I tried to overload GetEditCtrl().解决方案Quote:explanation about link between CEdit and CEditView
CEditView
is a bit special. While not inherited formCEdit
, it is behaving like one. See afxext.inl:
// CEditView // NOTE: The cast in GetEditCtrl is ugly, but must be preserved for compatibility. // CEdit is not related to CEditView by inheritance so we must be careful to ensure // that CEdit remains a binary compatible subset of CEditView. _AFXEXT_INLINE CEdit& CEditView::GetEditCtrl() const { return *(CEdit*)this; }
The solution is to implement the required functionality in yourCEditView
derived class.
If you have the source code of an extendedCEdit
class, copy the required code portions to yourCEditView
based class and prefix access to allCEdit
members withGetEditCtrl()
.
See CEditView Class[^], where it shows the parent class, so you can see what it inherits.
这篇关于重载cedit并在ceditview中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!