ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > N.A.N.Y. 2013

NANY 2013 Withdrawn: Bead Designer

<< < (4/4)

Renegade:
There's quite a bit of information out there on serialization.

https://duckduckgo.com/?q=serialize+a+control+in+delphi

I don't know enough about Delphi specifically, but... the principles are pretty general.

If you have 2 objects there, I'd probably just create an:

object[2]

Then fill it like:

object[0] = obj1;
object[1] = obj2;

Then serialize that. It's very simple and uncomplicated, but certainly doesn't allow for changing "file formats" later on. Something like "filename.<version>.<extension>" could help solve that problem easily though. Not the neatest solution, but workable and certainly a lot less work than creating a customized file format.


However, looking at your code, you've got an array in there, so it might be just as easy to create an XML file with something like this:


--- Code: Text ---<Grid>  <rows count="2">    <row position="1">      <col position="1">        <data>blue</data>      </col>      <col position="2">        <data>red</data>      </col>    </row>    <row position="2">      <col position="1">        <data>green</data>      </col>    </row>  </rows></Grid>
Or something like that. There are many ways, and that's just one very simple example. Not a very good one though... Just illustrating... The point is that you can create the entire grid in XML and pretty much do whatever you want. However, it is more complex than doing simple binary serialization. The good news is that there are lots of XML libraries to help out. :)

I like XML as it is very simple to use, and if designed right, is nicely compatible going forwards or backwards.

Renegade:
Well, after looking into serializing controls in .NET, looks like a custom class is needed as the default controls are not marked as serializable. Not sure what that means for Delphi, but it is one thing to consider. i.e. Can the object be serialized?

wraith808:
I sent a reply... since she's posted the original code here, I figured no harm in posting my alterations for any that are interested. (App, if you want me to take it down, just let me know).

app103:
Been messing around a bit while I avoid the big issue, switched to StringGrid to see if it somehow makes things easier (not entirely sure yet), and managed to get image export working (png), so that's a step in the right direction.

@wraith: Thanks for the help...I'll see if I can wrap my head around what you did, later, when things are a lot quieter here, probably late tonight when the noise makers are all asleep.

wraith808:
TStringGrid is a better choice in general- TDrawGrid is usually only used if you are making a totally custom data storage and grid.  The most basic difference is TStringGrid has a data storage mechanism behind it- TDrawGrid has no such thing.  And though it's called TStringGrid, you can draw anything with it if you override the draw method.

A couple of links on the subject:
http://borland.newsgroups.archived.at/public.delphi.ide.general/200703/0703298244.html
http://www.festra.com/wwwboard/messages/2241.html

I was originally going to ask you if you really needed to use a TDrawGrid or would a TStringGrid work- but as I was able to get the save working, I backed off of asking that. :)  But yeah... TStringGrid is probably the way to go, even if you use my method.  You can even store the TBead object in the cell on the grid to get rid of the extra data structure, and iterate through the grid instead of the array when saving/loading.

Navigation

[0] Message Index

[*] Previous page

Go to full version