Max Property (ScrollBar Object)

Applies to TestComplete 14.91, last modified on July 20, 2021

Description

Returns the maximum (rightmost or bottommost) position for the thumb.

Declaration

TestObj.Max

Read-Only Property Integer or Float (depends on the controls' library)
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Property Value

An integer or a float value that specifies the maximum position of the thumb (see Remarks).

Remarks

The Max property returns a float value for the WPF ScrollViewer and JavaFX ScrollPane controls. For other controls, it returns an integer value.

This is an arbitrary value set by the developer, often 100. If the ScrollBar object was obtained from a window that does not have the corresponding scroll bar, Max, Min and Pos all return 0.

Example

The following code snippet moves the scroll bar thumb.

JavaScript, JScript

function TestScrollBar()
{

  var VScrollBar, HScrollBar, Min, Max;
  // Obtains the ScrollBar object corresponding to the tested object’s vertical scroll bar
  VScrollBar = Aliases.TestedApp.TestForm.TextBox.VScroll;

  // Obtains the ScrollBar object corresponding to the tested object’s horizontal scroll bar
  HScrollBar = Aliases.TestedApp.TestForm.TextBox.HScroll;

  // Obtains the bottommost position of the scroll bar thumb
  Max = VScrollBar.Max;
  // Obtains the topmost position of the scroll bar thumb
  Min = VScrollBar.Min;
  // Moves the thumb to the middle of the vertical scroll bar
  VScrollBar.Pos = (Max - Min) / 2;

  // Obtains the rightmost position of the scroll bar thumb
  Max = HScrollBar.Max;
  // Obtains the leftmost position of the scroll bar thumb
  Min = HScrollBar.Min;
  // Moves the thumb to the middle of the horizontal scroll bar
  HScrollBar.Pos = (Max - Min) / 2;

}

Python

def TestScrollBar():

  # Obtains the ScrollBar object corresponding to the tested object's vertical scroll bar
  VScrollBar = Aliases.TestedApp.TestForm.TextBox.VScroll

  # Obtains the ScrollBar object corresponding to the tested object's horizontal scroll bar
  HScrollBar = Aliases.TestedApp.TestForm.TextBox.HScroll

  # Obtains the bottommost position of the scroll bar thumb
  Max = VScrollBar.Max
  # Obtains the topmost position of the scroll bar thumb
  Min = VScrollBar.Min
  # Moves the thumb to the middle of the vertical scroll bar
  VScrollBar.Pos = (Max - Min) / 2

  # Obtains the rightmost position of the scroll bar thumb
  Max = HScrollBar.Max
  # Obtains the leftmost position of the scroll bar thumb
  Min = HScrollBar.Min
  # Moves the thumb to the middle of the horizontal scroll bar
  HScrollBar.Pos = (Max - Min) / 2

VBScript

Sub TestScrollBar

  Dim VScrollBar, HScrollBar, Min, Max
  ' Obtains the ScrollBar object corresponding to the tested object’s vertical scroll bar
  Set VScrollBar = Aliases.TestedApp.TestForm.TextBox.VScroll

  ' Obtains the ScrollBar object corresponding to the tested object’s horizontal scroll bar
  Set HScrollBar = Aliases.TestedApp.TestForm.TextBox.HScroll

  ' Obtains the bottommost position of the scroll bar thumb
  Max = VScrollBar.Max
  ' Obtains the topmost position of the scroll bar thumb
  Min = VScrollBar.Min
  ' Moves the thumb to the middle of the vertical scroll bar
  VScrollBar.Pos = (Max - Min) \ 2

  ' Obtains the rightmost position of the scroll bar thumb
  Max = HScrollBar.Max
  ' Obtains the leftmost position of the scroll bar thumb
  Min = HScrollBar.Min
  ' Moves the thumb to the middle of the horizontal scroll bar
  HScrollBar.Pos = (Max - Min) \ 2

End Sub

DelphiScript

procedure TestScrollBar();
var VScrollBar, HScrollBar, Min, Max;
begin

  // Obtains the ScrollBar object corresponding to the tested object’s vertical scroll bar
  VScrollBar := Aliases.TestedApp.TestForm.TextBox.VScroll;

  // Obtains the ScrollBar object corresponding to the tested object’s horizontal scroll bar
  HScrollBar := Aliases.TestedApp.TestForm.TextBox.HScroll;

  // Obtains the bottommost position of the scroll bar thumb
  Max := VScrollBar.Max;
  // Obtains the topmost position of the scroll bar thumb
  Min := VScrollBar.Min;
  // Moves the thumb to the middle of the vertical scroll bar
  VScrollBar.Pos := (Max - Min) / 2;

  // Obtains the rightmost position of the scroll bar thumb
  Max := HScrollBar.Max;
  // Obtains the leftmost position of the scroll bar thumb
  Min := HScrollBar.Min;
  // Moves the thumb to the middle of the horizontal scroll bar
  HScrollBar.Pos := (Max - Min) / 2;

end;

C++Script, C#Script

function TestScrollBar()
{

  var VScrollBar, HScrollBar, Min, Max;
  // Obtains the ScrollBar object corresponding to the tested object’s vertical scroll bar
  VScrollBar = Aliases["TestedApp"]["TestForm"]["TextBox"]["VScroll"];

  // Obtains the ScrollBar object corresponding to the tested object’s horizontal scroll bar
  HScrollBar = Aliases["TestedApp"]["TestForm"]["TextBox"]["HScroll"];

  // Obtains the bottommost position of the scroll bar thumb
  Max = VScrollBar["Max"];
  // Obtains the topmost position of the scroll bar thumb
  Min = VScrollBar["Min"];
  // Moves the thumb to the middle of the vertical scroll bar
  VScrollBar["Pos"] = (Max - Min) / 2;

  // Obtains the rightmost position of the scroll bar thumb
  Max = HScrollBar["Max"];
  // Obtains the leftmost position of the scroll bar thumb
  Min = HScrollBar["Min"];
  // Moves the thumb to the middle of the horizontal scroll bar
  HScrollBar["Pos"] = (Max - Min) / 2;

}

See Also

Min Property (ScrollBar Object)
Pos Property (ScrollBar Object)

Highlight search results