Delphi 视觉组件 - 远离 TFrame 基础?
我有一个从 TFrame 构建的视觉组件(但随后注册到调色板等); 它工作得很好,我喜欢能够使用 IDE 直观地构建它。
我现在想创建一个相关组件的“家族”,为此,我想创建该组件的超类,然后从那里继承该组件和其他组件。
我确信有很多方法可以做到这一点,但我发现自己想知道:是否有一个工具可以将 *.DFM 文件(即 Forms 或 TFrames)转换为原始 Object Pascal 构造函数 代码? 想想从哪里开始使用可视化表单或 TFrame 是件好事,但随后在某个时刻打破该继承,并用实质上替代 DFM 文件流的构造函数替换构造函数。
一如既往,所有的想法/意见都受到赞赏。
I have a visual component that I built from a TFrame (but then registered to the palette, etc); it works great and I loved being able to build it VISUALLY using the IDE.
I would now like to create a "family" of related components, and to do so, would like to create a superclass of this component, and then inherit this component and others from there.
There are a lot of ways to do this, I'm sure, but I'm finding myself wondering: Is there a tool that will convert *.DFM files (i.e. Forms or TFrames) to raw Object Pascal constructor code? Thinking of where it w/b nice to begin w/a visual form or TFrame, but then break from that inheritance at some point, and replace the constructor w/what is essentially a replacement for streaming from the DFM file.
As always, all thoughts / input appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GExperts“组件到代码”,为选定的组件生成代码。
像图像这样的财产,您必须亲自签名。
GExperts "Component To Code", generate the code for selected components.
Property like images you have to sign by yourself.
乍一看有点好奇为什么要这样做...您可以从 IDE 中的表单/框架继承。
取决于您的 Delphi 版本,在 Delphi 2009 中,文件 -> 新建,然后选择可继承项并选择您要继承的表单/框架。 在以前的版本中,您可以选择“文件”-“新建”,然后会出现一个项目名称选项卡以及可供选择的所有项目表单的列表。
非常方便! 您最终会得到不同风格的表单/框架,并且您之后创建的几乎所有内容都是其中之一的后代。
A little curious why you'd want to do this at first glance... You can inherit from forms/frames in the IDE.
Depends on your version of Delphi, in Delphi 2009, File->New and then select Inheritable Items and pick the Form/Frame of yours that you want to inherit from. In previous versions, you'd pick File-New and there would be a tab for the project's name and a list of all the projects forms to select from.
It's quite handy! You end up with different flavors of Forms/Frames and just about everything you create afterwards is a descendant of one of them.
我赞同 Cesar 的 GExperts 评论,并补充说图像可以包含在资源文件中(和名称),然后 INCed 到 PAS 文件中。
I second the GExperts comment by Cesar, and would add that images can be included (and names) in Resource files and then INCed into the PAS file.