Description
Use the Height
property to obtain or set the form height, in pixels.
Declaration
Applies To
The property is applied to the following object:
Property Value
An integer value that specifies the form height, in pixels.
Remarks
If a user form’s AutoSize
property is set to True and the form is invisible on screen, TestComplete returns 0 when you try to get the value of the form’s Height
property. To get the actual height value, call the ShowModal
method right before obtaining the height value.
Example
The following code snippet sets the form’s caption, size and initial position on the screen, displays the form and checks which form button the user has clicked to close the form.
JavaScript, JScript
{
var TestForm, mr;
// Obtains the user form
TestForm = UserForms.FormByName("TestForm");
// Sets the form’s caption
TestForm.Caption = "Press any button";
// Sets the coordinates of the form’s top edge
TestForm.Left = 500;
TestForm.Top = 500;
// Sets the form’s size
TestForm.Width = 214;
TestForm.Height = 100;
// Displays the form and checks what button the user has pressed
mr = TestForm.ShowModal();
if (mr == mrOK)
ShowMessage("The OK button was pressed");
else
ShowMessage("The Cancel button was pressed");
}
Python
def FormTest():
# Obtains the user form
TestForm = UserForms.FormByName["TestForm"]
# Sets the form's caption
TestForm.Caption = "Press any button"
# Sets the coordinates of the form's top edge
TestForm.Left = 500
TestForm.Top = 500
# Sets the form's size
TestForm.Width = 214
TestForm.Height = 100
# Displays the form and checks what button the user has pressed
mr = TestForm.ShowModal()
if mr == mrOK:
ShowMessage("The OK button was pressed")
else:
ShowMessage("The Cancel button was pressed")
VBScript
Dim TestForm, mr
' Obtains the user form
Set TestForm = UserForms.FormByName("TestForm")
' Sets the form’s caption
TestForm.Caption = "Press any button"
' Sets the coordinates of the form’s top edge
TestForm.Left = 500
TestForm.Top = 500
' Sets the form’s size
TestForm.Width = 214
TestForm.Height = 100
' Displays the form and checks what button the user has pressed
mr = TestForm.ShowModal
If mr = mrOK Then
ShowMessage "The OK button was pressed"
Else
ShowMessage "The Cancel button was pressed"
End If
End Sub
DelphiScript
var TestForm, mr;
begin
// Obtains the user form
TestForm := UserForms.FormByName('TestForm');
// Sets the form’s caption
TestForm.Caption := 'Press any button';
// Sets the coordinates of the form’s top edge
TestForm.Left := 500;
TestForm.Top := 500;
// Sets the form’s size
TestForm.Width := 214;
TestForm.Height := 100;
// Displays the form and checks what button the user has pressed
mr := TestForm.ShowModal;
if mr = mrOK then
ShowMessage('The OK button was pressed')
else
ShowMessage('The Cancel button was pressed');
end;
C++Script, C#Script
{
var TestForm, mr;
// Obtains the user form
TestForm = UserForms["FormByName"]("TestForm");
// Sets the form’s caption
TestForm["Caption"] = "Press any button";
// Sets the coordinates of the form’s top edge
TestForm["Left"] = 500;
TestForm["Top"] = 500;
// Sets the form’s size
TestForm["Width"] = 214;
TestForm["Height"] = 100;
// Displays the form and checks what button the user has pressed
mr = TestForm["ShowModal"]();
if (mr == mrOK)
ShowMessage("The OK button was pressed");
else
ShowMessage("The Cancel button was pressed");
}
See Also
ClientHeight Property
ClientWidth Property
Left Property
Top Property
Width Property