如何在 VCL 组件的派生类中隐藏继承的 __published 属性?
我基于现有的 VCL 组件创建了一个新的 VCL 组件。我现在想要做的是从 ini 文件而不是属性检查器设置密码和用户名属性。
我在上面的 delphi 论坛上读到,你无法取消发布属性,唯一的解决方法是将属性重新声明为只读。我尝试了这个,但它所做的只是使属性只读并在对象检查器中变灰。虽然这可行,但我更希望该属性根本不可见。
__property System::UnicodeString 密码 = {read=FPassword};
预先感谢您提供任何帮助或 C++ VCL 组件编写教程的链接。我用的是CB2010
I have created a new VCL component based on an existing VCL component. What I want to do now is set the Password and Username properties from an ini file instead of the property inspector.
I read on the delphi forum above you cannot unpublish a property and that the only workaround is to redeclare the property as read-only. I tried this but it all it does is make the property read only and grayed out in the object inspector. While this could work I would prefer if the property wasn't visible at all.
__property System::UnicodeString Password = {read=FPassword};
Thanks in advance for any help or links to c++ VCL component writing tutorials. I am using CB2010
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查找
DesignIntf.UnlistPublishedProperty
。请参阅此步骤。Look up
DesignIntf.UnlistPublishedProperty
. See this tread.定义的语言不允许您隐藏已发布的属性。
我会使用聚合而不是继承,即创建一个新的 VCL 组件,将其方法委托给现有组件,然后您就可以完全控制要发布的属性。
The language as defined will not allow you to hide published properties.
I would make use of aggregation instead of inheritance i.e. Create a new VCL component that delegates its methods to the existing component, you then have full control over what properties to publish.
我知道这是一个老问题,但仍然没有关于如何执行此操作的良好文档。我自己最终来到这里试图解决这个问题,并认为其他人出于同样的原因来到这里应该得到关于如何做到这一点的解释。
在撰写本文时,我使用的是 C++ Builder 10.4(悉尼)。
有一个名为
designide
的包,您需要将其添加为项目的引用。lib\ 中查找
或designide.bpi
win32\releaselib\win64\release
取决于您的目标。还必须更新包含路径,以便它可以找到头文件。
$(BDSINCLUDE)\windows\vcl\design
在您的代码中添加
#include
并使用函数UnlistPublishedProperty()
取消发布包函数Register()
中的属性。I know this is an old question, but there is still no good documentation on how to do this. I ended up here myself trying to figure this out and thought that others ending up here for the same reason deserve an explanation on how to do this.
In the writing moment, I'm using C++ Builder 10.4 (Sydney).
There is a package called
designide
that you need to add as a reference to your project.designide.bpi
inlib\win32\release
orlib\win64\release
depending on your target.The include path must also be updated so it can find the header file.
$(BDSINCLUDE)\windows\vcl\design
In your code add
#include <DesignIntf.hpp>
and use the functionUnlistPublishedProperty()
to unpublish properties in your package functionRegister()
.