CreateForm

From SCAR Divi Manual
Revision as of 17:01, 25 June 2011 by Freddy (talk | contribs) (Description)
Jump to: navigation, search

Definition

<func>function CreateForm: TForm;</func>

Availability

SCAR Divi 3.00 > Current

Description

This function creates and returns a new form object of the TForm class which is stored internally in the forms resource manager. It will be automatically freed if the script stops and you have not freed it yourself with FreeForm. You have to use FreeForm to destroy a form created with CreateForm, trying to achieve this any other way will result in errors.

Example

var
  TestForm: TForm;

procedure TestForm_Init;
begin
  TestForm := CreateForm;
  with TestForm do
  begin
    Left := -1147;
    Top := 335;
    Caption := 'Test Form';
    ClientHeight := 202;
    ClientWidth := 304;
    Color := clBtnFace;
    Font.Charset := DEFAULT_CHARSET;
    Font.Color := clWindowText;
    Font.Height := -11;
    Font.Name := 'Tahoma';
    Font.Style := [];
    OldCreateOrder := False;
    PixelsPerInch := 96;
  end;
end;

procedure TestForm_SafeInit;
var
  v: TVariantArray;
begin
  SetLength(v, 0);
  ThreadSafeCall('TestForm_Init', v);
end;

function TestForm_ShowModal: Boolean;
begin
  Result := TestForm.ShowModal = mrOk;
end;

function TestForm_SafeShowModal: Boolean;
var
  v: TVariantArray;
begin
  SetLength(v, 0);
  Result := ThreadSafeCall('TestForm_ShowModal', v);
end;

begin
  TestForm_SafeInit;
  if TestForm_SafeShowModal then
    WriteLn('Form returned modalresult ok');
  FreeForm(TestForm);
end.

See Also