Pos Property (ScrollBar Object)

Applies to TestComplete 15.0, last modified on October 22, 2021

Description

Specifies the current scroll bar position.

Declaration

TestObj.Pos

Read-Write 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 current position of the thumb (see Remarks).

Remarks

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

Pos is greater than or equal to Min and less than or equal to Max. Assigning a value beyond these bounds has no effect at all. Pos grows rightwards or downwards. 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

ScrollBar.Max
ScrollBar.Min

Highlight search results