Determining the Number of Tab Rows in Desktop Windows Applications

Applies to TestComplete 15.70, last modified on December 17, 2024

Tab controls can contain any number of tabbed pages, each having a tab. Tabs can be displayed in one row or in several rows. When a tab control uses single-row mode, some tabs are invisible. When multi-line mode is used, all of the tabs are displayed. You may need to determine the number of rows that the tabs are grouped into.

While testing tab 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.

To work with standard tab controls, you can use the Win32TabControl object. This object corresponds to tab controls whose class names are listed in the Object Mapping options of the current project. Use the wRowCount property to determine the number of tab rows. The following example obtains the number of rows and posts an informative message to the test log:

JavaScript, JScript

function main()
{
var p, l, w, TabControl, RowNumber;

  // Open My Computer
  WshShell.Run("explorer.exe /e, /select,C:\\", SW_SHOWNORMAL);

  // Obtain the tab control
  p = Sys.Process("Explorer");
  l = p.Window("ExploreWClass", "My Computer", 1);
  l.Keys("~T[Up][Enter]");
  w = p.Window("#32770", "Folder Options", 1);
  TabControl = w.Window("SysTabControl32", "", 1);
  
  // Determine the number of rows
  RowNumber = TabControl.wRowCount;
  if (RowNumber !=1)
    Log.Message("Tab control contains" & RowNumber& " rows of tabs.")
  else
    Log.Message("Tab control contain one row of tabs.");
}

Python

def Main():

  # Open My Computer
  WshShell.Run("explorer.exe /e, /select,C:\\", SW_SHOWNORMAL)

  # Obtain the tab control
  p = Sys.Process("Explorer")
  l = p.Window("ExploreWClass", "My Computer", 1) 
  l.Keys("~T[Up][Enter]")
  w = p.Window("#32770", "Folder Options", 1)
  TabControl = w.Window("SysTabControl32", "", 1)
  
  # Determine the number of rows
  RowNumber = TabControl.wRowCount
  if (RowNumber !=1):
    Log.Message("Tab control contains" & RowNumber& " rows of tabs.")
  else:
    Log.Message("Tab control contain one row of tabs.")

VBScript

Sub main
Dim p, l, w, TabControl, RowNumber

  ' Open My Computer
  Call WshShell.Run("explorer.exe /e, /select,C:\", SW_SHOWNORMAL)

  ' Obtain the tab control
  Set p = Sys.Process("Explorer")
  Set l = p.Window("ExploreWClass", "My Computer", 1)
  l.Keys "~T[Up][Enter]"
  Set w = p.Window("#32770", "Folder Options", 1)
  Set TabControl = w.Window("SysTabControl32", "", 1)
  
  ' Determine the number of rows
  RowNumber = TabControl.wRowCount
  If RowNumber <>1 Then
    Log.Message("Tab control contains" & RowNumber& " rows of tabs.")
  Else
    Log.Message("Tab control contain one row of tabs.")
  End If
End Sub

DelphiScript

procedure main();
var p, l, w, TabControl, RowNumber;
begin

  // Open My Computer
  WshShell.Run('explorer.exe /e, /select,C:\', SW_SHOWNORMAL);
  
  // Obtain the tab control
  p := Sys.Process('Explorer');
  l := p.Window('ExploreWClass', 'My Computer', 1);
  l.Keys('~T[Up][Enter]');
  w := p.Window('#32770', 'Folder Options', 1);
  TabControl := w.Window('SysTabControl32', '', 1);
  
  // Determine the number of rows
  RowNumber := TabControl.wRowCount;
  if (RowNumber <>1)
  then 
    Log.Message('Tab control contains' + RowNumber + ' rows of tabs.')
  else
    Log.Message('Tab control contain one row of tabs.');
end;

C++Script, C#Script

function main()
{
var p, l, w, TabControl, RowNumber;

  // Open My Computer
  WshShell["Run"]("explorer.exe /e, /select,C:\\", SW_SHOWNORMAL);

  // Obtain the tab control
  p = Sys["Process"]("Explorer");
  l = p["Window"]("ExploreWClass", "My Computer", 1);
  l.Keys("~T[Up][Enter]");
  w = p["Window"]("#32770", "Folder Options", 1);
  TabControl = w["Window"]("SysTabControl32", "", 1);
  
  // Determine the number of rows
  RowNumber = TabControl.wRowCount;
  if (RowNumber !=1)
    Log["Message"]("Tab control contains" & RowNumber& " rows of tabs.")
  else
    Log["Message"]("Tab control contain one row of tabs.");
}

See Also

Working With Tab Controls in Desktop Windows Applications
wRowCount Property (Tab Controls)

Highlight search results