Use "singleton" style to create single copies of forms : LUSENET : OCI Best Practices : One Thread

If you need to have a single copy of a form created you can have it autocreated. However, the autocreate feature stores the reference to the form in the interface variable named after your form. This is error prone becuase the variable can be over-written. It's better to do the following:

o Delete the variable named after your form

o Create a implementation variable (which is how private class variables are coded in Delphi) named after your form; e.g., PrivateForm1: TForm1;

o Create a interface function named after your form; e.g., function Form1: TForm1;

o The function is coded like this example:

function Form1: TForm1;
  if (PrivateForm1 = NIL)
    then PrivateForm1 := TForm1.Create(Application);
  Result := PrivateForm1;

-- Anonymous, July 07, 1998

Moderation questions? read the FAQ