Tip: Easy Modal Forms (I think)

Quote
In article <4hq740$...@news2.nkn.net> esimp...@eramp.net "Evan Simpson" writes:
> I also wanted to pass parameters to a standard function that would set
> standard varying properties of the form instance.  I discovered that
> defining the following in a form's public section works:

> class procedure TForm2.ShowDialog(i: Integer; s: String);
> begin
>   with Self.Create(nil) do try
>     Label1.Caption:=s;
>     Label1.Left:=i;
>     ShowModal;
>   finally
>     Free;
>   end;
> end;

Another work around for avoiding repeated code is to use a global
(formless) unit which includes the following type declaration and
procedure:

type aFormType = class of tform;

procedure modalForm( formType : aFormtype ; callingForm : tForm);

var form : tform;

begin
   form:= formtype.create( callingForm);
   try
      if (form.showModal = 0)
         then {do nothing};
   finally
      form.free;
   end;
end;

The "if --- then {do nothing}" is a result of the compile time error
checks options which are set.

This allows any part of the application to include the line:

   modalform(tAnotherForm, self);

--
regards

Dave Gray                                 Nailsea Bristol UK 01275 857746
Bespoke Engineering & Technical Software       da...@davegray.demon.co.uk