UserForm.ResetForm Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The ResetForm method restores the initial settings of all the properties and events of the user form and its components.

The form’s initial settings are those that were specified before starting the script execution.

Declaration

UserForm.ResetForm()

Result None

Applies To

The method is applied to the following object:

Result Value

None.

Example

The following example changes the form's properties, displays the form on the screen, then resets the form’s initial state and displays the form on the screen again.

JavaScript, JScript

function Test()
{
  var SampleForm;

  // Obtains the user form by its name
  SampleForm = UserForms.FormByName("SampleForm");
  // Changes the user form’s properties
  SampleForm.Caption = "Press any button";
  SampleForm.Width = 150;
  SampleForm.Height = 120;
  // Displays the user form
  SampleForm.ShowModal();
  …

  // After the user form has been closed, resets the form's state
  SampleForm.ResetForm();
  // Displays the user form with the initial properties
  SampleForm.ShowModal();
  …

}

Python

def Test():
  # Obtains the user form by its name
  SampleForm = UserForms.FormByName["SampleForm"]
  # Changes the user form's properties
  SampleForm.Caption = "Press any button"
  SampleForm.Width = 150
  SampleForm.Height = 120
  # Displays the user form
  SampleForm.ShowModal()
  # ...
  # After the user form has been closed, resets the form's state
  SampleForm.ResetForm()
  # Displays the user form with the initial properties
  SampleForm.ShowModal()
  # ...

VBScript

Sub Test

  Dim SampleForm

  ' Obtains the user form by its name
  Set SampleForm = UserForms.FormByName("SampleForm")
  ' Changes the user form’s properties
  SampleForm.Caption = "Press any button"
  SampleForm.Width = 150
  SampleForm.Height = 120
  ' Displays the user form
  SampleForm.ShowModal
  …

  ' After the user form has been closed, resets the form's state
  SampleForm.ResetForm
  ' Displays the user form with the initial properties
  SampleForm.ShowModal
  …

End Sub

DelphiScript

procedure Test();
var SampleForm;
begin
  // Obtains the user form by its name
  SampleForm := UserForms.FormByName('SampleForm');
  // Changes the user form’s properties
  SampleForm.Caption := 'Press any button';
  SampleForm.Width := 150;
  SampleForm.Height := 120;
  // Displays the user form
  SampleForm.ShowModal;
  …

  // After the user form has been closed, resets the form's state
  SampleForm.ResetForm;
  // Displays the user form with the initial properties
  SampleForm.ShowModal;
  …

end;

C++Script, C#Script

function Test()
{
  var SampleForm;

  // Obtains the user form by its name
  SampleForm = UserForms["FormByName"]("SampleForm");
  // Changes the user form’s properties
  SampleForm["Caption"] = "Press any button";
  SampleForm["Width"] = 150;
  SampleForm["Height"] = 120;
  // Displays the user form
  SampleForm["ShowModal"]();
  …

  // After the user form has been closed, resets the form's state
  SampleForm["ResetForm"]();
  // Displays the user form with the initial properties
  SampleForm["ShowModal"]();
  …

}

See Also

Working With User Forms in Tests

Highlight search results