SimpleGraph's new object save to file

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

SimpleGraph's new object save to file

Postby BlackJack » August 19th, 2008, 1:48 am

Kambiz,I have some new questions,please help me.

I create some new Objects, want to save to file,but when I use SaveToFile mothed,find it can't to save ](*,) .I viewed the source of SimpleGraph.pas,which is save the List of TObject.if i want to save my Objects to file,i should to modefy the source of SimpleGraph.pas,shouldn't I? :cry:

I really don't want to modefy the source of SimpleGraph.pas,because if i do it , :-k the Component will lost commonality,do you have a good idea?

Thanks~~~ :)
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing

Postby Kambiz » August 19th, 2008, 3:39 am

Your objects and their published properties should be saved automatically, without need to modify SG.

The objects are not saved, or they cannot be loaded? Do you get any error message?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby BlackJack » August 19th, 2008, 6:07 am

no error messages

i define new object by subclassing from existing objects, add some new properties.

i viewed the source of SG, the SaveToFile mothed read all objects as TObjects, but TObjects don't have my properties in my new Objects, so it can't be save i think.
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing

Postby Kambiz » August 19th, 2008, 7:16 am

As you can see in the SG code, all graph object clsses are derived from TGraphObject class, and SG saves/loads them correctly. So, there must be a problem in your definition.

By the way, did you register your class to SG by calling TSimpleGraph.Register static method?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby BlackJack » August 19th, 2008, 9:15 am

Thanks Kambiz.
You are right , i'm wrong.
I don't put my new properties in published,I put them in public.
By the way, what's distinction of them?
Thank you again~~~
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing

Postby Kambiz » August 19th, 2008, 7:16 pm

When a property is published, Delphi keeps its runtime type information (RTTI) and saves/loads its value to/from streams.

For example, if you look at DFM file of a form, all stored properties are published by the form or components/controls on the form.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby BlackJack » August 20th, 2008, 1:15 am

I know it, Thanks~~~.
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron