Tip: Easy Modal Forms (I think)

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

type aFormType = class of tform;

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

var form : tform;

   form:= formtype.create( callingForm);
      if (form.showModal = 0)
         then {do nothing};

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);


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