Determining the Bounds of a Status Bar Pane

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

While testing status bar controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

When working with a status bar control you may need to obtain information about the bounds of its panes. Since the status bar controls listed in the project’s Object Mapping options are associated with the Win32StatusBar object, you can use the object's specific properties and methods to work with the status bar controls and their panes.

You can use the wItemBounds property to determine the bounds of the pane specified by its index or caption. This property returns the Bounds object that contains the parent-relative coordinates of the lower-right and upper-left corners, the height and width of a bounding rectangle.

The following code snippet posts the height and width of the specified status bar pane to the test log:

JavaScript, JScript

function Main()
{
  var p, w, StatusBar, PaneBounds;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys.Process("Explorer");
  w = p.Window("ExploreWClass", "My Documents", 1);
  StatusBar = w.Window("msctls_statusbar32", "", 1);
  
  // Obtain the pane's bounds and post this information to the log
  PaneBounds = StatusBar.wItemBounds(2);
  Log.Message("Height: " + PaneBounds.Height);
  Log.Message("Width: " + PaneBounds.Width);
}

Python

def Main():

  # Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL)
  
  # Obtain the status bar control
  p = Sys.Process("Explorer")
  w = p.Window("ExploreWClass", "My Documents", 1)
  StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  # Obtain the pane's bounds and post this information to the log 
  PaneBounds = StatusBar.wItemBounds[2]
  Log.Message("Height: " + PaneBounds.Height)
  Log.Message("Width: " + PaneBounds.Width)

VBScript

Sub Main
  Dim p, w, StatusBar, PaneBounds

  ' Open My Documents
  Call WshShell.Run("explorer.exe", SW_NORMAL)
  
  ' Obtain the status bar control
  Set p = Sys.Process("Explorer")
  Set w = p.Window("ExploreWClass", "My Documents", 1)
  Set StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  ' Obtain the pane's bounds and post this information to the log
  Set PaneBounds = StatusBar.wItemBounds(2)
  Log.Message("Height: " & PaneBounds.Height)
  Log.Message("Width: " & PaneBounds.Width)
End Sub

DelphiScript

procedure Main();
var 
  p, w, StatusBar, PaneBounds: OleVariant;
begin
  // Open My Documents
  WshShell.Run('explorer.exe', SW_NORMAL);
  
  // Obtain the status bar control
  p := Sys.Process('Explorer');
  w := p.Window('ExploreWClass', 'My Documents', 1);
  StatusBar := w.Window('msctls_statusbar32', '', 1);
  
  // Obtain the pane's bounds and post this information to the log
  PaneBounds := StatusBar.wItemBounds(2);
  Log.Message('Height: ' + aqConvert.VarToStr(PaneBounds.Height));
  Log.Message('Width: ' + aqConvert.VarToStr(PaneBounds.Width));
end;

C++Script, C#Script

function Main()
{
  var p, w, StatusBar, PaneBounds;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys["Process"]("Explorer");
  w = p["Window"]("ExploreWClass", "My Documents", 1);
  StatusBar = w["Window"]("msctls_statusbar32", "", 1);
  
  // Obtain the pane's bounds and post this information to the log
  PaneBounds = StatusBar.wItemBounds(2);
  Log["Message"]("Height: " + PaneBounds["Height"]);
  Log["Message"]("Width: " + PaneBounds["Width"]);
}

See Also

Working With Status Bar Controls
wItemBounds Property (StatusBar Controls)
Bounds Object

Highlight search results