Implements a date/time picker control.

datetimepicker.pas contains an implementation of a date/time picker control patterned after the Delphi VCL control with the same name. It contains a cross-platform LCL control which would resemble the VCL TDateTimePicker control as much as possible.

TDateTimePicker does not use the native Windows control. It is descended from the TCustomControl class in order to be cross-platform. It has been tested on Windows with Win32/64 and QT widgetsets, as well as on Linux with QT and GTK2 widgetsets.

Please note that the TDateTimePicker control does not descend from TEdit, so it does not have the unnecessary caret just like its VCL counterpart.

datetimepicker.pas is part of DateTimeCtrls package for Lazarus.

Original Author:

Zoran Vučenović, January and February 2010. Зоран Вученовић, јануар и фебруар 2010.

LICENSE

Modified LGPL -- see the file COPYING.modifiedLGPL.

NO WARRANTY

There is no warranty whatsoever.

Original documentation is located on the Lazarus Wiki at:

DateTimeCtrls Package

Contains the value used to represent a null or unspecified TDateTime value.
Largest date value that can be entered for the date/time picker control.

Represents December 31, 9999.

Smallest date value that can be entered for the date/time picker control.

TCalendar does not accept dates before 14. sep. 1752 on Windows OS (see the implementation of TCustomCalendar.SetDateTime). In the Delphi help, it is documented that Windows controls act strangely with dates older than 24. sep. 1752. Actually, TCalendar control has problems displaying dates before 1. okt. 1752. Try putting one calendar on the form, run the application and see what september 1752. looks like.

In the LCL, dates behave uniformly as much as possible -- we do not allow dates before 1. okt. 1752. on any OS (even if the platform allows previous dates).

Contains the class reference used to create calendar controls for the platform.

Defaults to TLCLCalendarWrapper if not assigned in the control. Used in the constructor for the calendar form in the implementation.

Record type used to represent Year, Month, and Day component values in a date.

Each member is a Word type, and contains values as returned from the DecodeDate routine in the FPC RTL. TYMD is used in the implementation of TCustomDateTimePicker when the date value is read or modified using properties or methods in the control.

Represents the Year for a date value.
Represents the Month number for a date value.
Represents the Day number for a date value.
Record type used to represent Hours, Minutes, Seconds, and Milliseconds component values in a time.
Represents the Hour in a time value (using the 24-hour clock).
Represents the Minute in a time value.
Represents the Second in a time value.
Represents the Milliseconds in a time value.
Represents the display order for the component values (parts) in a date.
Use Day, Month, Year display order.
Use Month, Day, Year display order.
Use Year, Month, Day display order.
Use the display order needed for the default format settings on the platform.
Indicates the display format for month names on the calendar dialog form for the control.

TMonthDisplay is the type used to represent the MonthDisplay property in TCustomDateTimePicker and descendants.

Uses the short month names in the default format settings for the platform.
Uses the long month names in the default format settings for the platform.
Uses the month names specified in the CustomMonthNames property for the date/time picker control.
Represents the component values (parts) displayed for a time value.

TTimeDisplay is the type used to implement the TimeDisplay property in TCustomDateTimePicker and descendants.

Displays the Hour and Minute parts of a time value.
Displays the Hour, Minute, and Second parts of a time value.
Displays the Hour, Minute, Second, and Millisecond parts of a time value.
Indicates whether a time value uses a 12-hour or a 24-hour clock.
Causes time values to have AM or PM suffixes.
Uses a 24-hour clock for a time value.
Indicates whether a date/time picker control displays a date, a time, or both values.
Displays a date value on a date/time picker control.
Displays a time value on a date/time picker control.
Displays both a date and a time value on a date/time picker control.
Range type which represents the text for the parts in a date/time value.

Contains the 1-based equivalent for the values TDateTimePart.

Represents the parts (component values) that can represented in a date/time picker control.

Values from TDateTimePart are stored in the TDateTimePart set type.

Represents the Day number part of a date.
Represents the Month number part of a date.
Represents the Year number part of a date.
Represents the Hour part of a time.
Represents the Minute part of a time.
Represents the Second part of a time.
Represents the Millisecond part of a time.
Represents the AM or PM suffix in a time using a 12-hour clock.
Range type for date or time parts (component values) which can be hidden on a date/time control.
Set type used to stored values from the TDateTimePart enumeration.
Set type used to stored values from the TDateTimePart enumeration which are effectively visible on a date/time control.
Represents arrow shapes which can be drawn for the drop-down button on a TDateTimePicker control.
Uses a small variant of the classic drop-down arrow (filled triangular shape).
Uses a larger variant of the classic drop-down arrow (filled triangular shape).
Uses a small variant of the modern drop-down arrow (single downward chevron).
Uses a larger variant of the modern drop-down arrow (single downward chevron).
Uses a filled triangular drop-down arrow with a notched stem.
Uses ThemeServices to drawn the shape for the drop-down arrow.
Represents the drop-down or button mode used for a date value on a TDateTimePicker control.

TDTDateMode is an enumerated type with values that represent the button style and display behavior used for a Date value in a date.time picker control. TDTDateMode is the type used to implement the DateMode property in TCustomDateTimePicker.

Displays a drop-drown button as used in a combo-box control, and opens a calendar dialog to select a date value.
Displays up and down buttons to select the value for the select text part in a date/time picker control.
Does not display button control(s) on a date/time picker control. Direct entry or the Up/Down cursor keys must be used to enter a date value for a date/time picker control.
Represents the alignment options for the calendar dialog on a TDateTimePicker control.

Used when the date/time picker is set to date (dtkDate) or date/time (dtkDateTime) kind. A Calendar dialog is not displayed to enter a time value for a date/time picker control.

Aligns the calendar dialog to the left-hand edge of the control.
Aligns the calendar dialog to the right-hand edge of the control.
Uses the value in BiDiMode to determine the alignment of the calendar dialog on the control.
Identifies the features or behaviors which can be enabled for a TDateTimePicker control.
The OnChange handler for the control is signalled when the date/time is programmatically changed.
Enables the date time picker if the check box is unchecked.
Automatically checks an unchecked check box when DateTime is changed. (Relevant when dtpoEnabledIfUnchecked is set).
Draws the button control for the date time picker using a flat appearance.
Moves to the first text on the date time picker when it receives focus. The control does not remember which part was previously selected.
Store values from the TDateTimePickerOption enumeration.

TDateTimePickerOptions is a set type used to store 0 or more values from the TDateTimePickerOption enumeration. The values represent the features or behaviors which are enabled for a TDateTimePicker control.

TDateTimePickerOptions is the type used to implement the Options property in TCustomDateTicker and its descendants.

Base class for date/time picker controls.

TCustomDateTimePicker is a TCustomControl descendant. It is the base class for date/time picker controls like TDateTimePicker and TDBDateTimePicker. The control allows the user to enter Date, Time, or DateTime values. It incorporates a button on the control to display a drop-down calendar for date values, or up and down buttons to increment and decrement the numeric values in a time. Individual parts in the date/time values can be changed using the Up and Down cursor keys, or by entering the value directly into the control.

TCustomDateTimePicker uses locale-specific settings to format and display date/time values by default, but allows these settings to be overridden. TCustomDateTimePicker ignores the BiDiMode setting when formatting date and time values, but does use the property to align the button(s) on the control.

TDBDateTimePicker
Handles the LM_KILLFOCUS message for the control.

WMKillFocus is a reintroduced method in TCustomDateTimePicker. It ensures that a LM_KILLFOCUS control message is handled properly when the control loses focus.

On Qt, WMKillFocus happens even when focus jumps to another form. This behavior differs from Win and Gtk 2 (where it happens only when the focus changes to another control on the same form.

WMKillFocus ensures that the ancestor method, which calls EditingDone and triggers the OnEditingDone event handler, is called only when the active form on the screen is not the calendar dialog form for the control. No actions are performed in the method when the focus change causes the calendar dialog form for the control to be activated.

Window message handled in the method.
Handles the LM_SIZE message for the control.

WMSize is a reintroduced method in TCustomDateTimePicker. It calls the inherited method (from TWinControl) on entry to calculate the position and bounds for the control on its Parent. It ensures that the button(s) for the control are resized when AutoResizeButton is set to True.

Window message with the new width and height for the control.
Gets the default dimensions for a new instance of the control.
TSize instance with the default width and height for a new instance of the class.
Validates and normalizes changes to date or time parts.

ConfirmChanges is a method used to validate and normalize changes to date or time parts (component values) when a value is modified by the end-user.

For a date value:

If user entered the year as one or two digits, it is adjusted to the range in the CenturyFrom, MinDate, and MaxDate properties.

For a time value:

Changing the value in the AM/PM part causes the Hour to be changed if its value is not valid for a 12-hour clock.

ConfirmChanges is called from the EditingDone method, and when the value for the ReadOnly property is changed.

Reverts changes to the DateTime value for the control.

UndoChanges is a method used to revert the DateTime property to its original value when editing is cancelled by the user.

UndoChanges is called when the VK_ESCAPE (Escape) key is handled for the control. It is also called from the UpdateDate method when an exception is handled while setting the date value for the control.

Creates and displays the drop-down calendar dialog for the control.

DropDownCalendarForm ensures that the form instance in the CalendarForm property is allocated, configured, and displayed. CalendarForm is the form the where the embedded calendar/time picker for the control is displayed, and its value is assigned in the method when:

- The control does not already have an assigned form instance in CalendarForm.
- Checked is set to True, or dtpoEnabledIfUnchecked has been enabled in Options property.
- The control is not configured as ReadOnly.

The value in CalendarForm is not updated and the form is not displayed at design-time.

DropDownCalendarForm is called when the drop-down button is clicked, or the Alt+Down cursor key is pressed in the edit for the control.

Gets the rectangle where the check box for the control is drawn.

Use ShowCheckBox to enable display of the check box for a date or date/time value on the control.

GetCheckBoxRect is called from the GetTextOrigin, MouseDown, MouseMove, and Paint methods when ShowCheckBox is enabled.

TRect instance with the bounds for the check box within the client area for the control.
True causes the value in IsRightToLeft to be ignored, and the check box is drawn on the left-hand side of the control.
Gets the date/time part (TDateTimePart) for the specified text part (TTextPart).

Converts the 1-based text part number to the 0-based value used in the TDateTimePart enumeration. Converts the ordinal value to match the display order specified in the DateDisplayOrder property.

Called from the GetSelectedDateTimePart method to get the selected text part in the control. Called from the MoveSelectionLR method to ensure that only date/time parts which are visible can be accessed using cursor key navigation.

TDateTimePart value for the specified text part.
Indicates the 1-based position for a text element displayed on the control.
Returns the part of the date/time value which is currently selected on the control.

GetSelectedDateTimePart is a TDateTimePart function which returns the currently selected part (or component value) on the date/ time picker control. The control can potentially display the values for 8 different segments in a date/time value: Year, Month, Day, Hour, Minute, Second, Millisecond, and an AM/PM indicator. These values are displayed based on the visibility and order indicated in properties like Kind, DateDisplayOrder, TimeDisplay, and TimeFormat.

GetSelectedDateTimePart calls GetDateTimePartFromTextPart to get the return value for the method using the position for the currently selected text segment. The return value is an ordinal position for the component value independent of the visibility or display order for the text values. See TDateTimePart for the values in the enumeration and their meanings.

GetSelectedDateTimePart is called from methods which navigate between the visible text segments, like: SelectDate, SelectTime, and SelectTextPartUnderMouse. It is also called when user changes are validated and applied to the date/time value for the control.

TDateTimePart enumeration value for the currently selected text part.
Performs actions needed when the Font for the control has been changed.

FontChanged is an overridden method in TCustomDateTimePicker. It ensures that the internal flag used to trigger recalculation of the sizes for text parts for the control is enabled. It calls the inherited method (in TCustomControl) prior to exiting from the method.

FontChanged is the routine used as the OnChange event handler for the Font property, and is assigned in the inherited constructor for the class instance.

FontChanged ensures that the new value for the Font property is also applied to the Canvas for the control. This includes the PixelsPerInch setting for the Font.

The object instance for the event notification.
Returns the upper-left corner of the rectangle where the text for the control is drawn.

The origin is offset for the InnerBorder used in BorderSpacing and the BorderWidth for the control. When ShowCheckBox is enabled, the origin is offset by the size for the check box including its border. If the control has a visible button, like the drop-down or up/down buttons, the client width is adjusted by the required amount. The Alignment property is also taken into consideration when the left edge in the return value is calculated.

GetTextOrigin is also used in calculating the preferred size for the control.

TPoint instance with the upper-left corner where the text for the control is drawn.
Ignores the value in IsRightToLeft when the origin for the text is determined.
Signals OnKeyDown event handlers (when assigned) and applies keys specific to the date/time picker control.

KeyDown is an overridden method in TCustomDateTimePicker. When the text parts or buttons are enabled for the control, the inherited method is called to signal assigned OnKeyDown event handlers using the values in Key and Shift.

If Key is not handled by an event handler, a private method is called to check and apply the keys specific to the control. The keys include the following:

VK_SPACE
  Toggles the state for the check box when ShowCheckBox is enabled.
VK_LEFT
  Moves the selection to the previous text part on the control.
VK_RIGHT
  Moves the selection to the next text part on the control.
VK_OEM_COMMA, VK_OEM_PERIOD, VK_DIVIDE, VK_OEM_MINUS, VK_SEPARATOR, VK_DECIMAL, VK_SUBTRACT
  Moves the text selection to the next text part on the control.
VK_UP
  Increments the value in the currently selected text part. The check box is checked when ShowCheckBox is enabled or dtpoAutoCheck is included in the Options for the control.
VK_DOWN
  If Shift contains ssAlt and the drop-down button is assigned, the calendar dialog for the control is displayed. Otherwise, the value in the currently selected text part is decremented. The check box is checked when ShowCheckBox is enabled or dtpoAutoCheck is included in the Options for the control.
VK_RETURN
  Calls the Editingdone method when ReadOnly is not enabled for the control.
VK_ESCAPE
  Calls UndoChanges and EditingDOne when ReadOnly is not enabled for the control.
VK_N
  Sets the DateTime property to the NullDate value when ReadOnly is not enabled for the control.

The Key argument is set to 0 (VK_UNKNOWN) if the Key is handled in an OnKeyDown event handler or handled internally by the control.

KeyDown is called from the KeyDownBeforeInterface method. It occurs after the Application, any forms with KeyPreview enabled, and the active DragManager have examined and possibly handled the key event.

TWinControl.OnKeyDown TWinControl.KeyDown TWinControl.KeyUp
Virtual key code for the key down event.
Shift, Ctrl, or Alt modifier for the key down event.
Validates and applies the specified character to the control.

KeyPress is an overridden method in TCustomDateTimePicker. It ensures that an internal update flag is maintained when the specified character is validated and applied to the control.

KeyPress calls the inherited method to signal the OnKeyPress event handler (when assigned). If Key is not set to VK_UNKNOWN (0) in the event handler, it is checked for the alphanumeric values allowed for the selected text part on the control and applied when ReadOnly is not set to True. UpdateDate is called to apply the new value for the DateTime property. The currently selected text part may be changed when a text segment is completely filled and AutoAdvance is enabled.

KeyPress is called from the DoKeyPress method when the parent form does not have KeyPreview enabled or does not handle the character code in Key. KeyPress is not called if csNoStdEvents has been included in the ControlStyle property.

See UTF8KeyPress for the actions performed for a UTF-8-encoded character in a key press.

Character examined and applied in the method.
Determines which text part should be selected in response to mouse message.

Used in MouseDown and DoMouseWheel methods.

Horizontal coordinate for the mouse pointer. Translated to a value relative to the text origin in the method.
Performs actions needed when the mouse pointer leaves the client rectangle for the control.

MouseLeave is an overridden method in TCustomDateTimePicker. It calls the inherited method on entry to signal the OnMouseLeave event handler (when assigned). MouseLeave ensures that the internal flag which tracks whether the mouse pointer is in the check box for the control is reset. The Invalidate method is called and causes the control to be redrawn.

MouseLeave is called from the CMMouseLeave method when a CM_MOUSELEAVE message is handled for the control.

Performs actions needed when a mouse move event is handled for the control.

MouseMove is an overridden method in TCustomDateTimePicker. It calls the inherited method on entry to update the drag manager (when active) and signals the OnMouseMove event handler (when assigned). It ensures that the internal flag used to track whether the mouse is in the check box for the control is updated when ShowCheckBox is enabled. The Invalidate method is called to redraw the control.

Shift, Ctrl, or Alt modifier for the mouse event.
Horizontal coordinate for the mouse pointer.
Vertical coordinate for the mouse pointer.
Performs actions needed when a mouse down event is handled for the control.

MouseDown is an overridden method in TCustomDateTimePicker. It ensures that the check box state is toggled if it is visible (ShowCheckBox is True) and the mouse is over the check box. If the mouse pointer is over one of the text parts, SelectTextPartUnderMouse is called to select the text value at the X coordinate. The control is focused if the Parent form can be given focus and allows tab navigation.

MouseDown calls the inherited method to activate the control, pass the mouse event to an active drag manager, and signal the OnMouseDown event handler (when assigned).

Mouse button for the event.
Shift, Ctrl, or Alt modifier for the mouse event.
Horizontal coordinate for the mouse down event.
Vertical coordinate for the mouse down event.
Signals the OnMouseWheel handlers, when the mouse wheel has been turned.

DoMouseWheel is an overridden method in TCustomDateTimePicker. It ensures that the selected text part for the control is updated when the control is Enabled.

WheelDelta determines whether the selected text part is incremented or decremented; it is incremented when WheelDelta is a positive integer value or 0.

DoMouseWheel do not call the inherited method - so it does not signal the OnMouseWheel, OnMouseWheelUp, or OnMouseWheelDown event handlers.

The return value is True if the value in the selected text part was changed in the method.

Returns True if the value in the selected text part (and the DateTime value) are updated in the method.
Shift, Ctrl, or Alt modifier for the mouse wheel event.
Direction and amount that the mouse wheel was moved. Negative values for a mouse wheel down event. Positive values (or 0) for a mouse wheel up event.
TPoint instance with the coordinates for the mouse pointer when the wheel event was detected.
Updates the control when the date value or the visual appearance for the control has been changed.

UpdateDate ensures that DateTime is in the range specified by the MinDate and MaxDate properties.

Calls the Change method if the user entered the value for the control, or dtpoDoChangeOnSetDateTime has been included in the Options property.

Gets the values for the visible text parts on the control. This includes clearing the values displayed for the text parts when DateIsNull returns True.

Invalidate is called and the control is subsequently redrawn.

UpdateDate is called when the values in DateTime, DateDisplayOrder, MonthDisplay, ShowMonthName, or LeadingZeros is changed for the control. It is also called when UndoChanges is called, when the hidden date/time parts are (re-)determined, and when character keys are applied to the selected text part for the control.

True if the OnChange event handler should be signalled when a value is assigned to the DateTime property.
Resets the selected text part (when needed) and signals the OnEnter event handler (when assigned) when the control receives focus.

DoEnter is an overridden method in TCustomDateTimePicker. It resets the internal member used to track the selected text part when dtpoResetSelection has been included in the Options property. DoEnter calls the inherited method (in TWinControl) to signal the OnEnter event handler (when assigned). Invalidate is called and the control is subsequently redrawn.

DoEnter is called from the CMEnter method when a CM_ENTER message is received for the control. This occurs when when the control receives focus, either by using keyboard navigation or by mouse click in the client area for the control.

TWinControl.Invalidate TWinControl.CMEnter TWinControl.OnEnter
Performs actions needed when the control loses focus.

DoExit is an overridden method in TCustomDateTimePicker. It calls the inherited method on entry to signal the OnExit event handler (if assigned) when the control loses focus. It calls Invalidate to redraw the control.

DoExit is called from the CMExit method when a CM_EXIT message is received for the control. It allows actions to be performed when the control loses focus, either by using keyboard navigation or by mouse click in the client area for another control.

TWinControl.DoExit
Performs actions needed when the control is clicked.

Click is an overridden method in TCustomDateTimePicker called when the control has been clicked using the mouse or its keyboard equivalent. It ensures the inherited method (in TControl) is not called if the control is not Enabled.

No actions are performed in the method if Enabled contains False or when ShowCheckBox is enabled but not Checked.

Click signals the OnClick event handler and/or executes the ActionLink when the control has been clicked.

TControl.Click
Performs actions needed when the control is double clicked.

DblClick is an overridden method in TCustomDateTimePicker. It ensures that the inherited method (in TControl) is not called if the control or its text parts are not Enabled. The inherited method signals the OnDblClick event handler (when assigned).

TControl.Enabled TControl.DblClick TControl.OnDblClick
Performs actions needed when a held mouse button is released over the control.
Mouse button for the event.
Shift, Ctrl, or Alt modifier for the mouse event.
Horizontal coordinate for the mouse pointer.
Vertical coordinate for the mouse pointer.
Handles a key up notification for the control.

KeyUp is an overridden method in TCustomDateTimePicker. It ensures that the inherited method is called only when the control and its text parts are Enabled, and a visible check box on the control is in the Checked state. The inherited method (in TWinControl) signals the OnKeyUp event handler (when assigned) using the values in Key and Shift as arguments.

KeyUp is called from the KeyUpBeforeInterface method. It occurs after forms with KeyPreview enabled or the active DragManager have examined and possibly handled the key event.

See KeyDown for the actions performed when the key down event has occurred.

TKeyEvent
Virtual key code for the key up notification.
Shift, Ctrl, or Alt modifiers for the key up notification.
Handles a key press notification for the specified UTF-8-encoded character value.

UTF8KeyPress is an overridden method in TCustomDateTimePicker. It ensures that the inherited method is called only when the control and its text parts are Enabled, and a visible check box on the control is in the Checked state. The inherited method (in TWinControl) signals the OnUTF8KeyPress event handler (when assigned).

UTF8KeyPress is called from the DoUTF8KeyPress method when the parent form does not have KeyPreview enabled or does not handle the character code in Key. UTF8KeyPress is not called if csNoStdEvents has been included in the ControlStyle property.

The handler routine in OnUTF8KeyPress can modify the value in the Key argument. It can set Key to an empty string if it is handled in the routine.

UTF-8-encoded character examined and potentially handled in the method.
Calculates the preferred width and height for the control including space for the visible button(s).

CalculatePreferredSize is an overridden method in TCustomDateTimePicker. It reimplements the method from the TWinControl ancestor, and does not call the inherited method.

CalculatePreferredSize measures and stores the widths for the text parts on the control (when needed), and determines the preferred size for the control within the ClientWidth and ClientHeight. If there are visible button(s) on the control, like the drop-down indicator or the up/down buttons, the width of the visible is added to the preferred width.

Preferred width in pixels for the text and buttons on the control.
Preferred height in pixels for the text and buttons on the control.
Not used in the method.
Sets the value for the BidiMode property.

Calls the inherited method to update the property value. Calls ArrangeCtrls to anchor and align the text parts and button(s) on the control.

TControl.BiDiMode
New value for the BiDiMode property.
Performs actions needed when the component has been loaded using the LCL streaming mechanism.
TWinControl.Loaded
Increments the internal member used to track the selected text part in the control.
Decrements the internal member used to track the selected text part in the control.
Increments the month number in the DateTime value.
Increments the year number in the DateTime value.
Increments the day number in the DateTime value.
Decrements the month number in the DateTime value.
Decrements the year number in the DateTime value.
Decrements the day number in the DateTime value.
Increments the hour number in the DateTime value.
Increments the minute number in the DateTime value.
Increments the second number in the DateTime value.
Increments the millisecond number in the DateTime value.
Decrements the hour number in the DateTime value.
Decrements the minute number in the DateTime value.
Decrements the second number in the DateTime value.
Decrements the millisecond number in the DateTime value.
Toggles between the 'AM' and 'PM' values and updates the hour in the DateTime value accordingly.
Changes the selected text part to the date/time part representing the day number.
Changes the selected text part to the date/time part representing the month.
Changes the selected text part to the date/time part representing the year number.
Changes the selected text part to the date/time part representing the hour number.
Changes the selected text part to the date/time part representing the minute number.
Changes the selected text part to the date/time part representing the second number.
Changes the selected text part to the date/time part representing the millisecond value.
Changes the selected text part to the date/time part representing the AM/PM indicator.
Sets the value for the Enabled property.

SetEnabled is the overridden write specifier for the Enabled property. It ensures that the button(s) and internal flags for the control are updated when the property value has been changed. It calls the Invalidate method to redraw the control after the changes have been applied.

TControl.Enabled
New value for the Enabled property.
Sets the value for the AutoSize property.

SetAutoSize is the overridden write specifier for the AutoSize property. It ensures that the InvalidatePreferredSize method is called before the value in the property is changed to True. It calls the inherited method prior to exit to apply the new value for the property.

New value for the AutoSize property.
Creates the handle for the widgetset class instance.

CreateWnd is an overridden method in TCustomDateTimePicker. It is needed to prevent a crash on Linux at design-time when anchoring child controls in the constructor. Anchoring of child controls has been moved to the ArrangeCtrls method and blocked until CreateWnd has been called. A boolean member was added (FDoNotArrangeControls) for the purpose and is set to False in the CreateWnd override after the inherited method is called. This allows ArrangeCtrls to safely perform anchoring for the child controls while ensuring the widget handle is valid.

TWinControl.CreateWnd
Sets the value for the internal member which tracks assignments using the MinDate or MaxDate values.
Value assigned to DateTime.
Anchors, aligns and resizes the control and its button(s).

Called when the value in BiDiMode or ShowCheckBox is changed, and when the window handle is created for the control in CreateWnd method.

Signals the OnChange event handlers assigned to the control when the DateTime value has been changed.
Signals the OnCheckBoxChange event handlers assigned for the control when the value in Checked has been changed.
Signals the OnDropDown event handler when the drop-down calendar dialog is displayed for the control.

Occurs when the dialog form for the drop-down calendar is displayed.

Signals the OnCloseUp event handler (when assigned) when the drop-down calendar dialog is closed for the control.
Sets the value in Checked to True when auto-check is enabled in the Options for the control.

Called when a new Date is selected on the drop-down calendar dialog and when keys applied to the control result in a new Date or Time value.

Applies an automatic layout policy and scaling proportions to the control.

DoAutoAdjustLayout is an overridden method in TCustomDateTimePicker. It calls the inherited method on entry to resize the control using the specified layout policy and scaling factors. It ensures that the width for drop-down or up/down button on the control is scaled from its default value to the PPI setting used in the Font.

Font scaling is performed in AutoAdjustLayout (when needed) and occurs prior to calling DoAutoAdjustLayout.

TControl.DoAutoAdjustLayout
Automatic layout policy applied in the method. It is a value from the TLayoutAdjustmentPolicy enumeration, and determines whether horizontal / vertical / or both sizes are adjusted in the method. It generally reflects the constraints for the device type where the application is running.
Scaling factor applied to the horizontal size in the control.
Scaling factor applied to the vertical size in the control.
Adds the specified handler routine to the internal list of OnChange event handlers for the control.

AddHandlerOnChange ensures that the internal TMethodList for the class instance has been allocated, and calls its Add method using the specified argument values.

Handler routine added to the handler list in the method.
True if the handler routine is stored as the first handler in the list. False if it is appended to end of the list.
Adds the specified handler routine to the internal list of OnCheckBoxChange events handlers for the control.

AddHandlerOnCheckBoxChange ensures that the internal TMethodList for the class instance has been allocated, and calls its Add method using the specified argument values.

Handler routine added to the handler list in the method.
True if the handler routine is stored as the first handler in the list. False if it is appended to end of the list.
Removes the specified OnChange handler routine from the internal list for the handler type.
Handler routine removed in the method.
Removes the specified OnCheckBoxChange handler routine from the internal list for the handler type.
Handler routine removed in the method.
Set with the date/time parts which are effectively hidden on the control.

EffectiveHideDateTimeParts is a read-only TEffectiveDateTimeParts property which contains the date/time parts which are effectively hidden for the control. Values are included in the set to indicate that specific date/ time parts are not visible for the configuration settings in the control, or explicitly hidden using the HideDateTimeParts property.

Properties which affect date/time part visibility include:

- Kind
- TimeDisplay
- TimeFormat
- HideDateTimeParts

The TDateTimePart values in EffectiveHideDateTimeParts are determined when a new value is assigned to one of these properties.

Indicates the effective display order for the date parts on the control.

EffectiveDateDisplayOrder is a read-only TDateDisplayOrder property which contains the effective order for the date parts displayed on the control. It reflects the order for the date found parts found when DateDisplayOrder contains ddoTryDefault.

The value for the property is assigned when the value in the DateDisplayOrder property is changed. It indicates the order for the date parts found in the date formats from DefaultFormatSettings. The tokens in the short date format are examined to determine the order for the date parts. If an order cannot be determined using the short date format, the long date format in DefaultFormatSettings is checked. If an order cannot be determined using either format value, the order indicated by ddoYMD is used.

SysUtils.DefaultFormatSettings
Border style drawn around the control.

BorderStyle is a TBorderStyle property redeclared in TCustomDateTimePicker to use bsSingle as the default value. Use bsNone to omit a border on the edges of the control.

TCustomControl.BorderStyle TBorderStyle
Allows the control to be automatically resized to the content displayed on the control.

AutoSize is redeclared in TCustomDateTimePicker to use True as the default value for the property. Changing the value to True causes InvalidatePreferredSize to be called prior to storing the new value for the property.

TControl.AutoSize TControl.InvalidatePreferredSize
Allows the user to navigate to / from the control by pressing the Tab or Shift+Tab keys.

Redeclared in TCustomDateTimePicker to use True as the default value for the property.

Indicates the Color from the Parent control is used when enabled.

ParentColor determines if the control should use the Color from the Parent control when enabled. ParentColor is redeclared in TCustomDateTimePicker to use False as the default value for the property.

TControl.ParentColor
Contains the threshold for the century used in two-digit year values.

CenturyFrom is a Word property with the year number used as the threshold for the century used in a year entered in two-digit format. The default value for the property is 1941, and causes two-digit year values to fall in the range 1941-2040.

Please note that MinDate and MaxDate properties can also have an influence on the value. For example, if the CenturyFrom is set to 1941 and MaxDate to 31-Dec-2010, entering 23 as a year value causes 1923 to be used because it cannot be 2023 due to MaxDate limit.

Defines the display order for the year, month, and day parts of the date.

DateDisplayOrder is a TDateDisplayOrder property. The enumeration value assigned to the property determines the order of the date parts displayed on the control.

doDMY
  Displays the date in Day, Month, and Year order.
ddoMDY
  Displays the date in Month, Day, and Year order.
ddoYMD
  Displays the date in Year, Month, and Day order.
ddoTryDefault
  When ddoTryDefault is set, the control tries to determine the order from the ShortDateFormat global variable.

It is similar to the DateOrder property in TDateEdit.

Use DateSeparator to specify the delimiter displayed between the date parts.

Use TimeSeparator and DecimalSeparator to specify the delimiters displayed between time parts on the control.

Set UseDefaultSeparators to True to use the locale-specific date and time separators found in the run-time FormatSettings.

User-specified upper limit for date values that can be entered or selected using the control.

MaxDate is a TDate property which indicates the largest date value that can be entered or selected using the control. Changing the value for the property causes the new value to validated and normalized.

MaxDate must contain a value which is valid for the TDateTime type, and within the range limits used for the drop-down calendar control in the class instance. The value in TheBiggestDate (31-Dec-9999) is used as the upper limit for the property value.

If the current value in DateTime is larger than the new property value, MaxDate is stored to the DateTime property.

Use MinDate to set the lower limit for the Date value in the control.

User-specified lower limit for date values that can be entered or selected using the control.
Contains the TDateTime value for the control.

DateTime is a TDateTime property with the value displayed and edited on the control. By default, the property is set to the value from SysUtils.Now in the constructor for the class instance.

DateTime is not a published property and does not appear in the object inspector at design-time. It can be accessed at run-time in program code. Its component values are accessible using the Date and Time properties for the control, which can be set in the object inspector using their design-time property editors.

DateTime is provided to allow reading or writing both the date and the time values at once in program code. The property contains the NullDate value when DateIsNull returns True. Changing the value for the property causes the UpdateDate method to be called to range limit, validate, and store the new value.

Use MinDate and MaxDate to define the range of dates allowed in the control. If they are not assigned, the values in TheSmallestDate and TheBiggestDate are used.

TCalendar does not accept smaller dates then 14-Sep-1752 on the Windows OS (see the implementation of TCustomCalendar.SetDateTime). The Delphi help documents that the Windows control behaves strangely when using dates prior to 24-Sep-1752. Actually, the TCalendar control has problems displaying dates before 1-Oct-1752. In the LCL, uniform behavior is achieved by using 1-Oct-1752 as the lower limit for the type.
Causes a trailing date separator to be displayed for the date value when enabled.

When set to True, the DateSeparator is displayed after the last date part in the display order. This property exists because in some languages the correct date format is 31. 1. 2010. including the last delimiter after the year value.

The default value for the property is False as assigned in the constructor for the class instance.

Indicates the value in the control cannot be changed when set to True.

ReadOnly is a Boolean property which indicates whether the Date/Time value can be changed using the control. The default value for the property is False.

Changing the value for the property causes user-specified values in text parts to be validated and applied before the property value is changed.

ReadOnly is used in methods which respond to mouse or key events in the control. The methods allow updates to occur only when ReadOnly is set to False. When set to True, the drop-down calendar for a date value cannot be displayed when the drop-down button is clicked.

Determines whether the date/time parts are displayed with or without leading zeros.

LeadingZeros is a Boolean property which determines whether leading zero ('0') characters are displayed for the numeric values in the date/time parts.

When LeadingZeros is set to True, numeric values are padded to the left with '0' characters until the maximum precision for a month, day, or hour date/time part is reached. When set to False, the Space character ( ' ' #32) is used to left-pad the numeric values.

LeadingZeros does not apply to one- or two-digit year values where CenturyFrom is used to fill the date part. It also does not apply to minute, second, or millisecond time parts where zero padding is always used.

Changing the value for the property causes the UpdateDate method to be called to validate and range limit the value in DateTime, and to signal the assigned OnChange event handlers for the control.

Text displayed when the DateTime value is a null date and the control does not have focus.

The default value for the property is 'NULL' as assigned in the constructor for the class instance.

When the control is focused, the text changes to its defined format but displays zeros or nines where appropriate. The user can set the date to the value in the NullDate constant by pressing the 'N' key when the NullInputAllowed property is True.

When TextForNullDate is set to empty string, zeros ('0') and nines ('9') are displayed even when control does not have focus. Zeros are used in the date value. Nines are used in the time value. To display an empty value, set TextForNullDate to a string with one or more space (' ' decimal #32) characters.

When True, the user can set the Date and DateTime values to the NullDate constant by pressing the 'N' key.
Event handler signalled when the DateTime value for the control has been changed.

OnChange is a TNotifyEvent property with the event handler signalled when the DateTime value is changed on the control. OnChange is signalled (when assigned) from the Change method. It normally occurs when the user interacts with the control - by assigning values directly to text parts or using the keys and buttons provided for the control.

Include the value dtpoDoChangeOnSetDateTime in the Options property to signal the OnChange event handler when a value is assigned to DateTime in program code.

Use the AddHandlerOnChange and Remove HandlerOnChange methods to assign additional OnChange handler routines for the control.

Event handler signalled when the Checked state for a check box on the control has been changed.
Event handler signalled when the drop-down calendar dialog for the control has been displayed.
Event handler signalled when the drop-down calendar dialog has been closed.
Displays a check box on the control when enabled.

ShowCheckBox is a Boolean property which displays a check box on the control when enabled.

When set to True, a check box is displayed on the control. By default, when unchecked, the display appears "grayed" and user interaction with the date/time parts is not possible. The control is still enabled, though, only in the sense that the check box remains enabled. This behavior may be changed if dtpoEnabledIfUnchecked is included in the Options property; this allows editing when the check box is not checked, and the programmer can decide how it will be used in the OnCheckBoxChange event.

When set to False, the check box is not displayed on the control.

The value in the BiDiMode property is used to determine the placement for the check box. When BiDiMode is set to bdLeftToRight, the check box is drawn on the left-hand edge of the control before the Date, Time or DateTime value. Any other value in BiDiMode causes the check box to be drawn on the right-hand edge of the control.

Indicates whether the check box for the control is in the checked state.

If ShowCheckBox is set to False, the property value is automatically set to True but is not used in the control.

Indicates the shape drawn for the drop-down arrow on the control.

ArrowShape is a TArrowShape property which indicates the shape drawn as the glyph for the drop-down button on the control. The default value for the property is asTheme, and causes the element detail from ThemeServices to be used to draw the shape.

See TArrowShape for more information about the values for the property and their meanings.

Changing the value for the property causes the button on the control to be redrawn by calling its Invalidate method.

Controls whether a date, time, or both can be edited using the control.

Kind is a TDateTimeKind property which controls the value displayed for the date time picker control. The default value for the property is dtkDate as assigned in the constructor for the class instance, and causes the Date value to be displayed and edited using the control.

Use dtkTime to display and edit the Time value. Use dtkDateTime to display and edit both the Date and Time values.

Use properties like DateDisplayOrder, TimeDisplay, and TimeFormat to control the order and formatting for the values displayed on the control.

Use DateMode to control the button(s) displayed for the control.

Use HideDateTimeParts to hide date/time parts which are normally displayed for the property settings in the control.

Separator used between the values in the Date for the control.

DateSeparator is a String property which defines the values used to separate the date, month and year parts for a Date value. The default value is assigned in the constructor, and uses the value in DefaultFormatSettings.DateSeparator.

Setting this property automatically sets the UseDefaultSeparators property to False. To ensure that date and time separators are set to the locale-specific system defaults, set the UseDefaultSeparators property to True.

Use TimeSeparator to specify the delimiter between the parts in the Time value.

Use DecimalSeparator to specify the notation used for the decimal point in a milliseconds value.

Separator used between the hours, minutes, and seconds in the Time for the control.

Defines the string used to separate hour, minute, second time parts on the control. Setting this property automatically sets the UseDefaultSeparators property to False. To ensure that date and time separators are set to the locale-specific system defaults, set UseDefaultSeparators property to True.

Notation used for the decimal point displayed prior to a millisecond value.

DecimalSeparator is a String property which contains the character(s) displayed as the decimal point for a milliseconds value in Time. The default value for the property is the locale-specific default FormatSettings.DecimalSeparator as assigned in the constructor for the class instance. Changing the value for the property causes the sizes for the text parts on the control to be recalculated, and the control is redrawn.

DecimalSeparator is used in the Paint method when the text for date or date/time parts and their separators are drawn on the control. It is not used when Kind is set dktDate to display a Date value.

Use DateSeparator to set the character(s) displayed between the text parts in a Date value.

Use TimeSeparator to set the character(s) displayed between the text parts in a Time value - excluding milliseconds.

Set the UseDefaultSeparators property to True to restore the values in DefaultFormatSettings to the DateSeparator, TimeSeparator, and DecimalSeparator properties.

Restores the default settings for the DateSeparator, TimeSeparator, and DecimalSeparator properties.

When this property is set to True, the values from DefaultFormatSettings are stored in the DateSeparator, TimeSeparator, and DecimalSeparator properties. Changing the value from True to False does not change the associated separators.

DefaultFormatSettings
Indicates whether a Time value uses a 12-hour or 24-hour clock.

TimeFormat is a TTimeFormat property which controls format used to display a Time value on the control. When TimeFormat contains tf12, a 12-hour clock is used to display the Time value and an AM/PM indicator is displayed. When set to tf24, a 24-hour clock is used for the Time value and the AM/PM indicator is hidden.

Changing the value for the property causes the visibility for the date/time parts to be recalculated. Date/time parts in the HideDateTimeParts property are hidden (when visible) on the control.

Use TimeDisplay to control the time parts displayed for a Time value. Seconds and milliseconds are optional.

Use HideDateTimeParts to hide any date/time part which would otherwise be visible for the settings in Kind, DateDisplayOrder, TimeDisplay and TimeFormat properties.

Indicates the time parts displayed and edited in the Time value.

TimeDisplay is a TTimeDisplay property which indicates the time parts in displayed and edited on the control. Values for the property include:

tdHM
  Displays the Hour and Minute parts of the Time value.
tdHMS
  Displays the Hour, Minute, and Second parts of the Time value.
tdHMSMs
  Displays the Hour, Minute, Second, and Millisecond parts of the Time value.

The default value for the property is tdHMS as assigned in the constructor for the class. Changing the value for the property causes the effective visibility of the date/time parts to be recalculated, and the control is redrawn.

TimeDisplay is used when Kind is set to dtkTime or dtkDateTime to make the Time value visible on the control. The visible date/time parts are drawn in the Paint method.

Use TimeFormat to specify whether the hour is displayed using a 24-hour clock or a 12-hour clock with AM/PM notation.

Use HideDateTimeParts to suppress display of a date/time part which is normally visible for the property settings in the control.

The Time value displayed and edited using the control.

Time is a TTime property which contains the time value displayed and edited on the control. The value in Time is read from and written to the DateTime property for the control. It contains the fractional portion of the DateTime value. Time can contains the value from the NullDate constant if DateTime does not have a valid value for the TDateTime type (IsNullDate).

The OnChange event handler is signalled (when assigned) if the value in Time is modified using the keyboard, the mouse, or cursor keys. It is not signalled when a value is assigned to the DateTime property in program code unless the value dtpoDoChangeOnSetDateTime has been included in the Options property.

Set Kind to dtkTime or dtkDateTime to display and edit the value in the Time property.

Use TimeDisplay to specify the time parts which are visible on the control.

Use TimeFormat to specify whether the hour value in Time uses a 24-hour clock or a 12-hour clock with AM/PM notation.

Use HideDateTimeParts to hide any date part which is normally visible for the settings in the properties.

The Date value displayed and edited using the control.

Date is a TDate property which contains the date value displayed and edited on the control. The value in Date is read from and written to the DateTime property in the control. It contains the Integer portion of the value in DateTime. Date can contain the value from the NullDate constant if DateTime does not have a valid value for the TDateTime type (IsNullDate).

The OnChange event handler is signalled (when assigned) if the value in Date is modified using the keyboard, the mouse, cursor keys, or the drop-down calendar for the control. It is not signalled when a value is assigned to the property in program code unless the value dtpoDoChangeOnSetDateTime has been included in the Options property.

Set Kind to dtkDate or dtkDateTime to display and edit the value in the Date property.

Use DateDisplayOrder to control the order of the parts displayed for the Date value.

Use HideDateTimeParts to hide any date part which is normally visible for the settings in the properties.

Indicates the button style used to display the drop-down calendar for a Date value on the control.

When DateMode is set to dmComboBox, there is a drop-down button displayed for the control - like on a combo-box. When the user clicks the button, the calendar control is displayed and allows the user to pick the date. When set to dmUpDown, a TUpDown button control is displayed to increment or decrement the value in the selected date/time part.

The button is displayed on the right-hand edge of the control when BiDiMode is set to bdLeftToRight. If BiDiMode is set to any other value, the button is displayed on the left-hand edge of the control.

Use the ArrowShape property to specify the shape used for the glyph on the drop-down button.

In my opinion the UpDown buttons aren't really useful in this control, they are provided for compatibility with Delphi's TDateTimePicker. Up and down keys can always serve for same purpose, so can mouse wheel.

TControl.BiDiMode
Enables updates to affected date/time parts when the value for a date/time part is cycled beyond its upper or lower limits.

Cascade is a Boolean property which indicates if a change to the value for a date/time part (like Day number) can increase or decrease the value in another date/time part (like Month or Year number).

For example, consider the date 1-Jan-2023 where the user decreases the Day number using the Down button or the cursor Down key.

If Cascade is enabled, the Day number is changed to 31 and both the Month and Year numbers are changed to reflect the roll-over condition. Month is changed to the previous month, and Year is changed reflect that the month is in the previous year. The change is cascaded to the affected date/time parts, and the resulting date is 31-Dec-2022.

If Cascade is set to False, the Day number is changed to 31 for the roll-over condition but the Year and Month values are unaffected. The resulting date is 31-Jan-2023.

The default value for the property is False, and causes the value in a date/time part to be cycled without affecting another date/time part. When enabled, it applies to all of the date/time part values.

Please note that Cascade does not apply to changes to the AM/PM indicator in a time value using a 12-hour clock (TimeFormat = tf12). A change to AM/PM always updates the hour value as needed regardless of the setting in Cascade.

Cascade is used in methods which increment or decrement values for date/time parts, like: IncreaseMonth, DecreaseMonth, IncreaseHour, DecreaseHour, et. al.

Enables automatic resizing of the button width proportionate to the height for the control.
Allows the text selection to automatically advance to the next date/time part when the current selection is filled with a valid value for the part.
Contains the user-specified set of date/time parts which are hidden on the control.

HideDateTimeParts is a TDateTimeParts property with the user-specified date/time parts which are hidden on the control. It can contain 0 (zero) or more values from the TDateTimeHidePart enumeration. Values in the set type can be assigned at design-time using a property editor in the Object Inspector, or at run-time using Include() or Exclude().

In most cases, use of HideDateTimeParts is not needed; properties like Kind and TimeDisplay can be used to control the hidden date/time parts. However, if more control is needed, the property can be used to hide any date/time part which would normally be visible for the property settings. It cannot be used to display a date/time part which is otherwise hidden for the property settings.

Please note that the AM/PM indicator cannot be added to the property; its visibility is controlled by the setting in TimeFormat.

HideDateTimeParts is combined with the effective date/time parts for the property settings at run-time, and stored in the EffectiveHideDateTimeParts property.

Some example use cases and their property settings include:

For a partial Date displayed as Jan 2023.

Kind := dtkDate; DateDisplayOrder := ddoMDY; MonthDisplay := mdShort; ShowMonthNames := True; HideDateTimeParts := [dtpDay];

For a partial Date displayed as January 31.

Kind := dtkDate; DateDisplayOrder := ddoMDY; MonthDisplay := mdLong; ShowMonthNames := True; HideDateTimeParts := [dtpYear];

For a time displayed as minutes, seconds, and milliseconds (like a short-duration elapsed time).

Kind := dtkTime; TimeDisplay := tdHMSMs; TimeFormat := tf24; HideDateTimeParts := [dtpHour];
Contains the calendar control class used on the drop-down calendar dialog.

When assigned, this property determines the type of the calendar control used on the drop-down calendar dialog. When set to Nil, which is the default, the value of the global variable DefaultCalendarWrapperClass is used.

Indicates the display format / length for month names on the control.

MonthDisplay is a TMonthDisplay property which indicates the format or length for month names displayed on the control when ShowMonthNames is enabled. Values for the property include:

mdShort
  Displays the short variant of month names for the month in the Date value. The month names contain the values from DefaultFormatSettings.ShortMonthNames.
mdLong
  Displays the long variant of month names for the month in the Date value. The month names contain the values from DefaultFormatSettings.LongMonthNames.
mdCustom
  Displays values from CustomMonthNames for the month in the Date value. An empty value in CustomMonthNames defaults to the value used when the property is set to mdLong.

The default value for the property is mdLong. Changing the value for the property causes the internal array for month names to be reloaded. If ShowMonthNames is enabled, the sizes needed for the date/time parts is recalculated and UpdateDte is called to force the control to be redrawn.

Set Kind to dtkDate or dtkDateTime to enabled display of the Date value on the control.

Use DateDisplayOrder to control order of the date parts displayed on the control.

Use HideDateTimeParts to hide a date/time part which is normally visible for the property settings in the control.

MonthDisplay is provided an alternative to use of the MonthNames property. In prior LCL versions, MonthNames needed access to the ShortMonthNames and LongMonthNames variables in the FPC RTL. These values have been deprecated in the RTL, and MonthNames now uses the values in DefaultFormatSettings.
DefaultFormatSettings
Controls the month names displayed when ShowMonthNames is set to True.

When ShowMonthNames is set to True, this property determines which month names should appear. If MonthNames is set to 'Short' or 'Long', then month names are set to ShortMonthNames or LongMonthNames respectively.

To set the month names explicitly, this property should be set to string which starts with a character which will be used to separate months and then twelve names separated by this character. For example: ',I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII' — roman numbers are used for months — the first character is comma, which means that comma is used to separate the months.

Another example: ';jan;feb;mar;apr;maj;jun;jul;avg;sep;okt;nov;dec'. So, the separator should be the first character, before the first month name, and then only if there are twelve month names separated by that separator, the format is valid.

The default value of this property is 'Long'.

Set Kind to dtkDate or dtkDateTime to enabled display of the Date value on the control.

Use DateDisplayOrder to control order of the date parts displayed on the control.

Use HideDateTimeParts to hide a date/time part which is normally visible for the property settings in the control.

Use of MonthNames is now largely redundant. The same functionality is available using MonthDisplay and CustomMonthNames. In prior LCL versions, MonthNames needed access to the ShortMonthNames and LongMonthNames variables in the FPC RTL. These values have been deprecated in the RTL, and MonthNames now uses the values in DefaultFormatSettings.
List of user-specified Month names displayed when MonthDisplay is set to mdCustom.

CustomMonthNames is a TStrings property with a list of custom month names displayed on the control. It is used when ShowMonthNames is set to True and MonthDisplay is set to mdCustom. It should contain 12 lines with the name for the corresponding month in the text.

Assign the values in the property prior to setting MonthDisplay to mdCustom. Any missing or empty line in CustomMonthNames is replaced with the value from DefaultFormatSettings.LongMonthNames when MonthDisplay is changed to mdCustom.

Set Kind to dtkDate or dtkDateTime to display a Date value on the control.

Use DateDisplayOrder to specify the display order for the date parts on the control.

Set ShowMonthNames to True to display month names instead of month numbers on the control.

Set MonthDisplay to mdCustom to enable use of the values in CustomMonthNames.

CustomMonthNames and MonthDisplay are provided an alternative to use of the MonthNames property. In prior LCL versions, MonthNames needed access to the ShortMonthNames and LongMonthNames variables in the FPC RTL. These values have been deprecated in the RTL, and MonthNames now uses the values in DefaultFormatSettings.
Displays month names instead of month numbers when enabled.

ShowMonthNames is a Boolean property which causes month names to be displayed instead of month numbers when set to True. When set to False, month numbers are displayed in the date part.

Use CustomMonthNames to specify a list of user-specified values used as the names for the months.

Use MonthDisplay to specify the format, length, and origin of the month names displayed on the control.

Use DateDisplayOrder to specify the display order for the date parts on the control.

Set Kind to dtkDate or dtkDateTime to display a Date value on the control.

Indicates whether the drop-down calendar dialog is visible for the control.

DroppedDown is a read-only Boolean property which indicates whether the drop-down button for the control has been clicked and the calendar control is visible. The property value is True when the internal calendar form has been assigned for the control in the DropDownCalendarForm method.

Alignment for the drop-down calendar dialog relative to the bounds for the control.
Alignment for the text displayed for the visible date/time parts on the control.

Alignment is redeclared in TCustomDateTimePicker. It has an overridden write specifier which ensures that the control is invalidated and redrawn when the property value has been changed. The default value for the property is taLeftJustify, and causes the text for the date/time parts to be left-aligned within the control bounds.

The value in Alignment does not affect the placement of the button on the control; use BiDiMode to specify where the button is drawn.

Use CalAlignment to specify the alignment of the drop-down calendar dialog relative the bounds for the control.

Set type with the optional features or behaviors enabled for the control.

dtpoDoChangeOnSetDateTime
  The OnChange handler will be called also when DateTime is programmatically changed.
dtpoEnabledIfUnchecked
  Enable the date time picker if the check box is unchecked.
dtpoAutoCheck
  Auto-check an unchecked check box when DateTime is changed (makes sense only if dtpoEnabledIfUnchecked is set).
dtpoFlatButton
  Use flat button for calendar picker.
dtpoResetSelection
  When the control receives focus, the selection is always in the first part (the control does not remember which part was selected).

Form instance where the date/time picker control is displayed.

CalendarForm is a read-only TCustomForm property which contains the form instance where the embedded calendar/time picker for the control is displayed. Its value is assigned and the form is displayed in the DropDownCalendarForm method, and occurs when:

- The control does not already have an assigned form instance in CalendarForm.
- Checked is set to True, or dtpoEnabledIfUnchecked has been enabled in Options property.
- The control is not configured as ReadOnly.

This occurs at run-time when the drop-down button for the control is clicked, or when Alt+Down is pressed in the edit control. CalendarForm is not assigned or displayed at design-time.

The value assigned to CalendarForm is freed when the form instance in the property is destroyed. It is automatically freed and recreated when the drop-down arrow for the control is created.

Constructor for the class instance.

Create is the overridden constructor for the class instance. It calls the inherited constructor on entry to ensure that the Canvas for the control is allocated.

Create sets the initial bounds for the control to the default size (102x35 pixels) for the class. It sets the default values for properties in the control, which includes:

- Kind (dtkDate)
- DateDisplayOrder (ddoTryDefault)
- DateMode (dmComboBox)
- TimeDisplay (tdHMS)
- TimeFormat (tf24)
- DateSeparator (DefaultFormatSettings.DateSeparator)
- TimeSeparator (DefaultFormatSettings.TimeSeparator)
- DecimalSeparator (DefaultFormatSettings.DecimalSeparator)
- UseDefaultSeparators (True)
- LeadingZeros (True)
- MonthDisplay (mdLong)
- ShowMonthNames (False)
- Cascade (False)
- AutoButtonSize (False)
- AutoAdvance (True)
- Options (an empty set)
- DateTime (SysUtils.Now)
- MinDate (TheSmallestDate)
- MaxDate (TheSmallestDate)
- CenturyFrom (1941)
- CustomMonthNames (Resources allocated and configured to redraw the control when changed).

Create sets the value for each of the text segments used during editing of the date or time parts to an empty string ('').

The effective display order and visibility for the date/time parts is initially determined in the method.

Owner of the class instance which receives notification events.
Destructor for the class instance.

Destroy is the overridden destructor for the class instance. It frees resources allocated in the class instance, including:

- The drop-down or up/down button.
- OnChange handler(s).
- OnCheckBoxChange handler(s).
- The TStringList instance for CustomMonthNames.

Destroy calls the inherited method prior to exit to free the class instance.

Returns True if the DateTime property does not contain a valid value for the TDateTime type.
IsNan IsInfinite MaxDateTime MinDateTime
Returns True if the DateTime property does not contain a valid date/time value.
Adjusts the selected text part to ensure it is on one of the values used for a Date.
Adjusts the selected text part to ensure it is on one of the values used for a Time.
Validates and applies the specified character to the control.

SendExternalKey handles the following character values in AKey:

'N', 'n'
  Applies the value in NullDate to the DateTime value for the control.
'0'..'9'
  Applied to the value for the selected text part.
'A', P'
  Applied to the AM/PM indicator in a 12-hour time value when selected.

Values in the LeadingZeros, AutoAdvance, and Options properties are enforced after the character value is applied to the control.

No actions are performed in the method if the control or its text parts are not Enabled, or ReadOnly is set to True.

Character value examined and optionally applied to the control.
Validates and applies the specified virtual key code to the control.

SendExternalKeyCode handles the following virtual key values in Key:

VK_N ('N')
  Sets DateTime to the NullDate value.
VK_0..VK_9 ('0'..'9')
  Applied to the value for the selected text part.
VK_A ('A'), VK_P ('P')
  Applied to the AM/PM indicator in a 12-hour time value when selected.

If the text parts are enabled for the control, the value in Key is converted to its character equivalent and SendExternalKey is used to apply the character value.

If text parts are not enabled, the following value is handled for the control:

VK_SPACE (#32)
  Toggles the check box state when ShowCheckBox is set to True.

Virtual key code examined and optionally applied to the control.
Removes all event handler routines for the specified object.

RemoveAllHandlersOfObject is an overridden method in TCustomDateTimePicker. It calls the inherited method on entry to remove all event handlers attached to the TObject instance in AnObject. It calls the RemoveAllMethodsOfObject method in the internal TMethodList instances in the control to free the handler types maintained in TCustomDateTimePicker.

TControl.RemoveAllHandlersOfObject TControlHandlerType TMethodList.RemoveAllMethodsOfObject
Object instance with the event handler routines removed in the method.
Implements the paint handler used to draw the control.

Paint is an overridden method in TCustomDateTimePicker. It performs actions needed to draw the date and/or time value(s) for the control. Paint extends the ancestor method (from TCustomControl) to perform drawing for the individual parts (component values) that are enabled and visible for the property settings in the control.

The values are drawn using methods in the Canvas for the control. This includes:

- The background for the control.
- The visible parts for the date / time value including the separators between the parts.
- The selected (highlighted) part in the editing control.
- The button(s) which display the calendar dialog, or increment and decrement the value for the selected part.

Paint calls the inherited method (in TCustomControl) prior to exit to signal the OnPaint event handler (when assigned).

Paint is called from the PaintWindow method, and occurs when a LM_PAINT message is handled for the control.

Performs actions needed when editing has been completed in the control.
Implements a date/time picker control.

TDateTimePicker is a TCustomDateTimePicker descendant. It provides a class used to enter Date, Time, or DateTime values. It incorporates a button on the control to display a drop-down calendar for date values, or up and down buttons to increment and decrement the numeric values in a time. Individual parts in the date/time values can be changed using the Up and Down cursor keys, or by entering the value directly into the control.

TDateTimePicker uses locale-specific settings to format and display date/time values by default, but allows these settings to be overridden. TDateTimePicker ignores the BiDiMode setting when formatting date and time values, but does use the property to align the button(s) on the control.

TDateTimePicker sets the visibility for properties, methods, and events introduced in ancestor classes. It also marks the MonthNames property as deprecated in the class instance.

TDBDateTimePicker
Compares the specified TDateTime values to determine if the are equal.

The return value is True when A and B contain the same TDateTime value, or both A and B contain an invalid date/time value.

Returns True when the two dates are equal or both dates are null.
TDateTime value compared in the routine.
TDateTime value compared in the routine.
Determines whether the specified TDateTime argument contains an invalid value for the TDateTime type.
IsNan IsInfinite MaxDateTime MinDateTime
Returns True if the specified value is Not A Number (NAN), contains the Infinite value, or is outside the minimum and maximum values for the type.
TDateTime value examined in the routine.
Returns a formatted debugging message representing the specified set of TDateTimePart values.
String with the formatted debugging message for the values.
Set of TDateTimePart values included in the return value.