Getting DateTimePicker Format in Desktop Windows Applications

Applies to TestComplete 15.46, last modified on January 09, 2023

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.

To determine whether the DateTimePicker control is used to select a date or time use the wIsDateFormat property of the Win32DateTimePicker object that is automatically associated with DateTimePicker controls whose class names are listed in the Object Mapping options of your project. The wIsDateFormat property returns True if the DateTimePicker control is used to select a date, and False if the DateTimePicker control is used to select time.

The following example demonstrates how you can determine whether the DateTimePicker control is used for date or time selection:

JavaScript, JScript

function main()
{
  var DateTimePicker, d;
   
  // Obtain the DateTimePicker control
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1);
   
  // Get the data format
  d = DateTimePicker.wIsDateFormat;
  Log.Message(d);
}

Python

def Main():
   
  # Obtain the DateTimePicker control
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  # Get the data format
  d = DateTimePicker.wIsDateFormat
  Log.Message(d)

VBScript

Sub main
  Dim DateTimePicker, d
   
  ' Obtain the DateTimePicker control
  Set DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
   
  ' Get the data format
  d = DateTimePicker.wIsDateFormat
  Log.Message d
End Sub

DelphiScript

procedure main;
var DateTimePicker, d;
begin

  // Obtain the DateTimePicker control
  DateTimePicker:= Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TDateTimePicker', '', 1);
   
  // Get the data format
  d := DateTimePicker.wIsDateFormat;
  Log.Message(d);
end;

C++Script, C#Script

function main()
{
  var DateTimePicker, d;
   
  // Obtain the DateTimePicker control
  DateTimePicker= Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TDateTimePicker", "", 1);
   
  // Get the data format
  d = DateTimePicker["wIsDateFormat"];
  Log.Message(d);
}

See Also

Working With DateTimePicker Controls in Desktop Windows Applications
wIsDateFormat Property (DateTimePicker Controls)
Obtaining DateTimePicker Date and Time in Desktop Windows Applications

Highlight search results