UserForm.OnHide Event

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

The OnHide event occurs when the user form is hidden. This happens when the form’s Hide method is called or the Visible property is set to False.

You can create an event handler for the OnHide event to perform certain actions when the form is hidden.

Declaration

OnHide(Sender)

Sender [in]    Required    A UserForm object    
Result None

Applies To

The property is applied to the following object:

Parameters

The event has the following parameter:

Sender

A UserForm object that raised the event.

Result Value

None.

Remarks

For information on how to create handlers for events of user forms and form components, see Handling Events in User Forms.

Example

The following example displays the user form and, when it is closed, posts a message to the test log:

JavaScript, JScript

// Shows the user form
function Main()
{
  var TestForm;
  …

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

}

// Event handler for the form’s OnHide event
function TestForm_OnHide(Sender)
{
  // Posts a message to the log when the form is hidden
  Log.Message("The user form has been closed");

}

Python

# Shows the user form 
def Main():
  # ...
  # Obtains the user form by its name
  TestForm = UserForms.FormByName["TestForm"] 
  # Shows the form
  TestForm.ShowModal()
  # ...

# Event handler for the form's OnHide event
def TestForm_OnHide(Sender):
  # Posts a message to the log when the form is hidden
  Log.Message("The user form has been closed")

VBScript

' Shows the 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

' Event handler for the form’s OnHide event
Sub TestForm_OnHide(Sender)

  ' Posts a message to the log when the form is hidden
  Log.Message("The user form has been closed")

End Sub

DelphiScript

// Shows the user form
procedure Main();
var TestForm;
begin
  …

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


end;

// Event handler for the form’s OnHide event
procedure TestForm_OnHide(Sender);
begin
  // Posts a message to the log when the form is hidden
  Log.Message('The user form has been closed');

end;

C++Script, C#Script

// Shows the user form
function Main()
{
  var TestForm;
  …

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


}

// Event handler for the form’s OnHide event
function TestForm_OnHide(Sender)
{
  // Posts a message to the log when the form is hidden
  Log["Message"]("The user form has been closed");

}

See Also

Handling Events in User Forms
UserForm.OnShow Event
UserForm.Hide Method
UserForm.Visible Property

Highlight search results