Getting the Number of Status Bar Panes in Desktop Windows Applications

Applies to TestComplete 15.68, last modified on October 16, 2024

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.

Status bars are usually divided into several panes, each containing certain information about the application’s status. If you need to obtain some information about the tested status bar control, you can use specific properties and methods of the Win32StatusBar object. TestComplete associates this object with all status bar controls whose class names are listed in the Object Mapping project’s options.

To determine the number of status bar panes, use the wPartCount property of the Win32StatusBar object. The following example posts the total number of status bar panes to the test log:

JavaScript, JScript

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

  // 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);
  
  // Post the total number of panes to the test log
  Log.Message("The total number of panes: " + StatusBar.wPartCount);
}

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)
  
  # Post the total number of panes to the test log
  Log.Message("The total number of panes: " + StatusBar.wPartCount)

VBScript

Sub Main
  Dim p, w, StatusBar

  ' 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)
  
  ' Post the total number of panes to the test log
  Log.Message("The total number of panes: " & StatusBar.wPartCount)
End Sub

DelphiScript

procedure Main();
var 
  p, w, StatusBar: 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);
  
  // Post the total number of panes to the test log
  Log.Message('The total number of panes: ' + aqConvert.VarToStr(StatusBar.wPartCount));
end;

C++Script, C#Script

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

  // 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);
  
  // Post the total number of panes to the test log
  Log["Message"]("The total number of panes: " + StatusBar["wPartCount"]);
}

See Also

Working With Status Bar Controls in Desktop Windows Applications
wPartCount Property (StatusBar Controls)

Highlight search results