Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save/reload the app in his current state

Posted on 1998-10-22
6
Medium Priority
?
278 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:jpdupont
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344035
Hi jdupont,

 use TFormStorage of the Freeware RxLib library!!!

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

Regards, Zif.
0
 

Author Comment

by:jpdupont
ID: 1344036
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
0
 
LVL 3

Expert Comment

by:Stefaan
ID: 1344037
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jpdupont
ID: 1344038
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
0
 

Expert Comment

by:john_m
ID: 1344039
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
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1344040
What you want to do is derive a class from TForm that overrides the Loaded and Close(?) methods (ie: immediately after the form is loaded from disk, and immediately before it is closed.

You then derive all your forms from this one (just change the class(TForm) to class(TMyForm)).

The method that is fired by closing the form iterates through all the components and for each writes out its component name (or index), and the necessary information

eg:
  with TIniFile.Create('MyIniFile') do
    for I := 0 to ComponentCount - 1 do
        if components[i] is TEdit then
          WriteString(Caption, 'Component'+inttostr(i), (Components[i] as TEdit).text)
       else
          if components[i] is TComboBox then
    // you get the picture

In the overriden loaded method of TMyForm reverse the procedure reading in the values for each of the components...

This should workj fairly well for what you want to do (especially if there are a limited number of types of components and the actual informaiton that needs to be stored is modest.

Cheers,

Raymond.        
 
       
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question