Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Save/reload the app in his current state

Posted on 1998-10-22
6
Medium Priority
?
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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