Delphi visual component - moving away from TFrame base? [closed]

不问归期 提交于 2019-12-07 12:25:28

问题


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.


回答1:


GExperts "Component To Code", generate the code for selected components. Property like images you have to sign by yourself.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/382562/delphi-visual-component-moving-away-from-tframe-base

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!