Free Form

This page shows the auto-generated code for a free form and a modified example that captures text as a modal form. A free form differs from an application form mainly because it allows multiple instances and gives tighter control over form lifetime.

unit_FreeForm (auto-generated)
unit _FreeForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm;

type
  TFreeForm = class(TUniForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses
  uniGUIApplication;

{$R *.dfm}

end.

Important characteristics:

  • No equivalent of the VCL global variable (the function that provides a global form instance is absent).

  • Requesting a free form implies the user wants behaviors not available with an application form:

    • Multiple instances of the form can be created (for example, several non-modal forms showing different records).

    • The user has tighter control over the form lifetime.

Notes about this modal example:

  • The owner of the free form is the instance handling the current session (not a global application variable).

  • The form is automatically released because FreeOnClose is true and a ModalResult value was assigned.

  • The local variable (frm) is released when it goes out of scope (after exiting GetText).

  • Free forms are convenient when exposing a service (like GetText) rather than exposing the form itself. The form can be created and freed entirely within the service implementation.