UserForm.Hide Method

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

The Hide method sets the form’s Visible property to False and thus hides the user form.

To display the form, use the Show or ShowModal method.

Declaration

UserForm.Hide()

Result None

Applies To

The method is applied to the following object:

Result Value

None.

Example

The following example shows one form in modal mode, and then, as a user clicks buttons, an additional user form is displayed or hidden on that form. The example assumes that the current project contains two user forms named TestForm and OptionsForm, and TestForm contains two buttons.

JavaScript, JScript

// Displays the main user form
function Main()
{
  var TestForm;

  …
  // Obtains the user form by its name
  TestForm = UserForms.FormByName("TestForm");
  // Shows the form
  TestForm.ShowModal()
  …
}

// Displays the additional user form
function TestForm_btn_ShowOptions_OnClick(Sender)
{
  var OptionsForm;
  // Obtains the user form by its name
  OptionsForm = UserForms.FormByName("OptionsForm");
  // Sets the user form width, height, position on screen and caption
  OptionsForm.Top = 120;
  OptionsForm.Left = 420;
  OptionsForm.Width = 470;
  OptionsForm.Height = 350;
  OptionsForm.Caption = "Options";
  // Shows the user form
  OptionsForm.Show();

}

// Hides the additional user form
function TestForm_btn_HideOptions_OnClick(Sender)
{
  var OptionsForm;
  // Obtains the user form by its name
  OptionsForm = UserForms.FormByName("OptionsForm");
  // Hides the user form
  OptionsForm.Hide();
}

Python

# Displays the main user form 
def Main():
  # ...
  # Obtains the user form by its name
  TestForm = UserForms.FormByName["TestForm"]
  # Shows the form
  TestForm.ShowModal()
  # ...
# Displays the additional user form
def TestForm_btn_ShowOptions_OnClick(Sender):
  # Obtains the user form by its name
  OptionsForm = UserForms.FormByName["OptionsForm"]
  # Sets the user form width, height, position on screen and caption
  OptionsForm.Top = 120
  OptionsForm.Left = 420
  OptionsForm.Width = 470
  OptionsForm.Height = 350
  OptionsForm.Caption = "Options"
  # Shows the user form
  OptionsForm.Show()

# Hides the additional user form
def TestForm_btn_HideOptions_OnClick(Sender):
  # Obtains the user form by its name
  OptionsForm = UserForms.FormByName["OptionsForm"]
  # Hides the user form
  OptionsForm.Hide()

VBScript

' Displays the main user form
Sub Main

  Dim TestForm

  …
  ' Obtains the user form by its name
  Set TestForm = UserForms.FormByName("TestForm")
  ' Shows the form
  TestForm.ShowModal
  …
End Sub

' Displays the additional user form
Sub TestForm_btn_ShowOptions_OnClick(Sender)

  Dim OptionsForm
  ' Obtains the user form by its name
  Set OptionsForm = UserForms.FormByName("OptionsForm")
  ' Sets the user form width, height, position on screen and caption
  OptionsForm.Top = 120
  OptionsForm.Left = 420
  OptionsForm.Width = 470
  OptionsForm.Height = 350
  OptionsForm.Caption = "Options"
  ' Shows the user form
  OptionsForm.Show

End Sub

' Hides the additional user form
Sub TestForm_btn_HideOptions_OnClick(Sender)

  Dim OptionsForm
  ' Obtains the user form by its name
  Set OptionsForm = UserForms.FormByName("OptionsForm")
  ' Hides the user form
  OptionsForm.Hide

End Sub

DelphiScript

// Displays the main user form
procedure Main();
var TestForm;

begin
  …
  // Obtains the user form by its name
  TestForm := UserForms.FormByName('TestForm');
  // Shows the form
  TestForm.ShowModal;
  …
end;

// Displays the additional user form
procedure TestForm_btn_ShowOptions_OnClick(Sender);
var OptionsForm;
begin
  // Obtains the user form by its name
  OptionsForm := UserForms.FormByName('OptionsForm');
  // Sets the user form width, height, position on screen and caption
  OptionsForm.Top := 120;
  OptionsForm.Left := 420;
  OptionsForm.Width := 470;
  OptionsForm.Height := 350;
  OptionsForm.Caption := 'Options';
  // Shows the user form
  OptionsForm.Show;

end;

// Hides the additional user form
procedure TestForm_btn_HideOptions_OnClick(Sender);
var OptionsForm;
begin
  // Obtains the user form by its name
  OptionsForm := UserForms.FormByName('OptionsForm');
  // Hides the user form
  OptionsForm.Hide;
end;

C++Script, C#Script

// Displays the main user form
function Main()
{
  var TestForm;

  …
  // Obtains the user form by its name
  TestForm = UserForms["FormByName"]("TestForm");
  // Shows the form
  TestForm["ShowModal"]()
  …
}

// Displays the additional user form
function TestForm_btn_ShowOptions_OnClick(Sender)
{
  var OptionsForm;
  // Obtains the user form by its name
  OptionsForm = UserForms["FormByName"]("OptionsForm");
  // Sets the user form width, height, position on screen and caption
  OptionsForm["Top"] = 120;
  OptionsForm["Left"] = 420;
  OptionsForm["Width"] = 470;
  OptionsForm["Height"] = 350;
  OptionsForm["Caption"] = "Options";
  // Shows the user form
  OptionsForm["Show"]();

}

// Hides the additional user form
function TestForm_btn_HideOptions_OnClick(Sender)
{
  var OptionsForm;
  // Obtains the user form by its name
  OptionsForm = UserForms["FormByName"]("OptionsForm");
  // Hides the user form
  OptionsForm["Hide"]();
}

See Also

Working With User Forms in Tests
UserForm.Show Method
UserForm.ShowModal Method
UserForm.Visible Property
UserForm.OnHide Event

Highlight search results