Getting Minimum and Maximum Allowed DateTimePicker Dates in Desktop Windows Applications

Applies to TestComplete 15.45, last modified on December 01, 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.

To get the minimum and maximum dates that can be selected in the DateTimePicker control, use the wMinDate and wMaxDate properties of the Win32DateTimePicker object. TestComplete associates this object with all DateTimePicker controls whose class names are listed in the Object Mapping options of your project. The wMinDate and wMaxDate properties return the minimum and maximum dates the DateTimePicker control can show.

The following example demonstrates how you can use these properties:

JavaScript, JScript

function main()
{
  var DateTimePicker;
    
  // Obtain the DateTimePicker control
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1);
    
  // Get the minimum and maximum dates
  Log.Message(DateTimePicker.wMinDate);
  Log.Message(DateTimePicker.wMaxDate);
}

Python

def Main():
    
  # Obtain the DateTimePicker control
  DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
    
  # Get the minimum and maximum dates
  Log.Message(DateTimePicker.wMinDate)
  Log.Message(DateTimePicker.wMaxDate)

VBScript

Sub main
Dim DateTimePicker
    
  ' Obtain the DateTimePicker control
  Set DateTimePicker= Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TDateTimePicker", "", 1)
     
  ' Get the minimum and maximum dates
  Log.Message DateTimePicker.wMinDate
  Log.Message DateTimePicker.wMaxDate
End Sub

DelphiScript

procedure main;
var DateTimePicker;
begin
  
  // Obtain the DateTimePicker control
  DateTimePicker:= Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TDateTimePicker', '', 1);
     
  // Get the minimum and maximum dates
  Log.Message(DateTimePicker.wMinDate);
  Log.Message(DateTimePicker.wMaxDate);
end;

C++Script, C#Script

function main()
{
  var DateTimePicker;
    
  // Obtain the DateTimePicker control
  DateTimePicker= Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TDateTimePicker", "", 1);
    
  // Get the minimum and maximum dates
  Log.Message(DateTimePicker["wMinDate"]);
  Log.Message(DateTimePicker["wMaxDate"]);
}

See Also

Working With DateTimePicker Controls in Desktop Windows Applications
wDate Property (DateTimePicker Controls)
wMaxDate Property (DateTimePicker Controls)
wMinDate Property (DateTimePicker Controls)

Highlight search results