I wrote a C++ builder component to display SVG files perform some stuff on them.
For now, I published a property named SvgFile (UnicodeString) which can be initialized in the IDE with the file name of the SVG file. This works fine. This property is saved into the DFM file and can be reloaded from it.
But I have to provide the SVG file with the application so I would like to save the SVG into the DFM file, as it is done with a TImage component.
I guess I have to write a TPropertyEditor and maybe a TPersistent class but I don't know what to do.
Does anyone could help me to do so ?
Edit 2013/01/17: here's a solution http://www.informit.com/articles/article.aspx?p=28278&seqNum=5
Thanks for your help.
You can create your own methods to read and write the properties by writing your own methods to perform the streaming of the binary data to and from a stream, and register them with the VCL/RTL streaming system using
DefineProperties
andDefineBinaryProperty
. There's an easy to follow example in the JEDI JVCL unit JVXSlider.pas:The Delphi streaming system will automatically call the appropriate methods for the defined property (in the example above, property
UserImages
) as needed to save to or read from the dfm file automatically; you never have the need to call them yourself.