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.
GExperts "Component To Code", generate the code for selected components. Property like images you have to sign by yourself.
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.
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