Working With DateTimePicker Controls' Check Boxes in Desktop Windows Applications

Applies to TestComplete 15.42, last modified on September 08, 2022

While testing combo box 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.

The DateTimePicker control can display a check box next to the date (time) selected in the control. You can determine whether the check box is visible or hidden using the wShowCheckbox property of the Win32DateTimePicker object. TestComplete associates this object with DateTimePicker controls whose class names are listed in the project's Object Mapping options. It returns False if the control’s check box is hidden; otherwise, True.

The following example demonstrates how you can determine whether the check box is hidden or not:

JavaScript, JScript

function main()
{
  var DateTimePicker;
   
  // Obtain the DateTimePicker object
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  // Determine whether the check box is visible or not
  Log.Message(DateTimePicker.wShowCheckBox);
}

Python

def Main():
   
  # Obtain the DateTimePicker object 
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  # Determine whether the check box is visible or not
  Log.Message(DateTimePicker.wShowCheckBox)

VBScript

Sub main
  Dim DateTimePicker
   
  ' Obtain the DateTimePicker object
  Set DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  ' Determine whether the check box is visible or not
  Log.Message(DateTimePicker.wShowCheckBox)
End Sub 

DelphiScript

procedure main;
var DateTimePicker;
begin

  // Obtain the DateTimePicker object
  DateTimePicker:= Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TDateTimePicker', '', 1);
   
  // Determine whether the check box is visible or not
  Log.Message(DateTimePicker.wShowCheckBox);
end;

C++Script, C#Script

function main()
{
  var DateTimePicker;
   
  // Obtain the DateTimePicker object
  DateTimePicker= Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TDateTimePicker", "", 1);
   
  // Determine whether the check box is visible or not
  Log.Message(DateTimePicker["wShowCheckBox"]);
}

You can select or clear the check box using the wChecked property of the Win32DateTimePicker object. It returns True if you can set a date (or time) in the DateTimePicker control by typing; otherwise, False.

The following code snippet demonstrates how you can clear the check box:

JavaScript, JScript

function main()
{
  var DateTimePicker;
  // Obtain the DateTimePicker control
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1);
   
  // Uncheck the check box
  DateTimePicker.wChecked = false;
}

Python

def Main():

  # Obtain the DateTimePicker control 
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  # Uncheck the check box
  DateTimePicker.wChecked = False

VBScript

Sub main
  Dim DateTimePicker
   
  ' Obtain the DateTimePicker control
  Set DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  ' Uncheck the check box
  DateTimePicker.wChecked = False
End Sub 

DelphiScript

procedure main;
var DateTimePicker;
begin
  
  // Obtain the DateTimePicker control
  DateTimePicker:= Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TDateTimePicker', '', 1);
   
  // Uncheck the check box
  DateTimePicker.wChecked := False;
end;

C++Script, C#Script

function main()
{
  var DateTimePicker;
   
  // Obtain the DateTimePicker control
  DateTimePicker= Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TDateTimePicker", "", 1);
  
  // Uncheck the check box
  DateTimePicker["wChecked"] = false;
}

When the check box is hidden (wShowCheckBox is False), wChecked is always True.

See Also

Working With DateTimePicker Controls in Desktop Windows Applications
wShowCheckBox Property (DateTimePicker Controls)
wChecked Property (DateTimePicker Controls)

Highlight search results