Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My suggestion is to <strong>decouple data from the GUI</strong> because this is causing your problem. If you have a form which gathers data from the user then you should distinguish the data from the form(TForm).</p> <p>For example, let's assume that you have some instance of TForm and a form on which is build from three fields, user name, age and location. You want from user to enter those tree things but when the user closes the form, you should pass inserted data to some object. Form closes, it is freed but the object persist. Then you pass this object to your manager object.</p> <p>Simple example:</p> <p>This is your record which will hold the data</p> <pre><code>type TGatheredData = record Name: String[40]; Age: Byte; Location: String[40]; end; </code></pre> <p>Your TForm1 might have an aditional constructor:</p> <pre><code>constructor TForm1.Create(AOwner: TComponent; var GatheredData: TGatheredData ); begin inherited Create(AOwner); FGatheredData := GatheredData; //you may want to deserialize GatheredData here and show the data in your form controls end; </code></pre> <p>You call it, pass GatheredData and then your are showing your form.</p> <p>Next, when closing form, you pick upd the data from the form controls.</p> <pre><code>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin if Self.ModalResult = mrOk then begin //serialize your object FGatheredData.Name := '';//name taken from control f.e. TEdit FGatheredData.Age := '';//name taken from control f.e. TSpinButton FGatheredData.Location := '';//name taken from control f.e. TEdit end; end; </code></pre> <p>Having this record of data, you may now pass it in the same manner to your Manager object. You decoupled data from GUI in this way, and you may easly plugin in your record to a number of different forms.</p> <p>Just remember to declare your record type in external unit and use that unit in your manager unit and forms unit.</p> <p>Hope this helps a little.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload