Link to home
Start Free TrialLog in
Avatar of jpdupont
jpdupont

asked on

Save/reload the app in his current state

Hi,
I want a way to save on disk my app (with all edits/... controls filled ... when the user close the app.
Then when he run the app again, all is in the same state.
(like in Turbovision "save the desktop" ???)

Thanks,

Jean-Pol
Avatar of ZifNab
ZifNab

Hi jdupont,

 use TFormStorage of the Freeware RxLib library!!!

http://torry.rimini.com/vcl/packs/rxlib.zip

Regards, Zif.
Avatar of jpdupont

ASKER

Thanks ZifNab,

I know RX (and use the lib intensivelly)
but RX form storage don't store all properties of all components : ex. ItemIndex is not stored. Don't store the memo text, ...

My app is a training app with 17 type of exercises : my form is created at run time (with all compenents). I read some tips about tFileStream.WriteComponent : Any way to do a "TFiletream.WriteForm(MyForm1)" and reload then with a readform(MyForm1) ?

Jean-Pol
Hi Jean-Pol,

Maybe you could store all those values (form size, form position, other properties) in the registry ?  Use the TRegistry class to create, read and save values to the registry.  Create a key for your application and keys for the components, then for each component property, create a value in the Component key of the registry.  When you restart the Application, you can read the Registry to see if there are values available, and use them to re-create the forms as they were the last time.

Creating a Key can be done using :

TRegistry.CreateKey('NameOfTheKeyToCreate');

Opening a Key :

TRegistry.OpenKey('NameOfTheKeyToOpen');

Reading the values from withing a key can be done with the ReadInteger, ReadString, ReadBool, ... methods and writing values using the WriteInteger, WriteString, WriteBool methods :

TRegistry.WriteString('Nameofthevalue','StringToWrite');
TRegistry.ReadString('NameOfTheValueToRead');

This way you can create a root key for your application, several sub keys for each form, with subkeys for the components and values for the properties (look in the Help files for more info on the TRegistry class).  

I hope that this will be of any help to you.

Greetings and best regards,


Stefaan Lesage.
Hi Stefaan,

Thanks for the answer.
I know registry - and registry use ;) -.
(I don't like to fill the registry with many data (memo / stringlist ...) I always chose inifiles. Easy to debug.)

When the user close the app, I don't know what is on the screen : (the exercises screens are drawned by a exercise script (18 different exercises scripts) with data structures filled by the user (some text typed by the user, user wav recording, user actions, user validations, ...) I want to take a snapshot of all this before the user close the app. Then , when he reload the app, he work instantly in the same "application state" he worked before he closed the app.

I want to automatically loop around the app/forms/data on the screen/... and save all this in a userfile (maybee many users on the same PC -> in a school). Then I want to read the userfile to reload all the screen/app parts, in the reverse order.

Regards,

Jean-Pol
If you want only visual components saving their state then you may like to look at the ReadComponent and WriteComponent methods of TxxxStream.

If you are wanting to save unpublished properties of both non-visual and visual components then I would advise you to look at the Spider classes. They can be found at the DSP.

If you want any more information after reading up on these two areas, then get in touch.

John_M
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial