Sign in Join
FPDoc Onlineexperiment

TDateEdit.ButtonClick procedure

Member of TDateEditprotectedIn unit EditBtn

Displays a pop-up calendar dialog when the Button for the grouped edit control is clicked.

Declaration

pascal
procedure ButtonClick; override

Description

ButtonClick is an overridden method in TDateEdit. It implements the virtual method defined in the ancestor class, and is called when the Button for the grouped edit control is clicked.

ButtonClick creates, displays, and executes a pop-up calendar dialog used to get a TDateTime value. The value in the Date property is passed as the initial date displayed on the dialog form. If Date contains the NullDate value, the current system date is used.

Values in the MinDate and MaxDate properties are used to validate and to limit the range of dates displayed on the pop-up calendar. When the properties contain non-zero values that are at least one day apart, they are used as the lower and upper limits for the value in Date. Otherwise, the MinDateTime and MaxDateTime RTL constants are used as the limits for the date value.

The ShowCalendarPopup routine is called to display and execute the dialog form. Set values in CalendarDisplaySettings and DefaultToday to control the appearance and behavior for the calendar on the dialog.

For the Windows platform, additional validation is performed to ensure that Date is within the range of values allowed for the native calendar control. The minimum date value is "1752-09-14" (September 14, 1752) for the start of the Gregorian calendar. The maximum date value is "9999-12-31" (December 31, 9999). This is done to prevent an exception when an invalid value is passed to the native calendar control. When DefaultToday is enabled, Date defaults to the current system date for a value outside this range. When not enabled, the MinDate and MaxDate values are used to range limit the date.

Assign a routine to the OnAcceptDate event handler to perform actions needed when a new date value is selected using the dialog. Enable FocusOnButtonClick to focus and optionally auto-select the value in the edit control after the dialog has been closed.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.