Contains extended dialogs used for Calendar, Calculator and Picture Open/Save tasks.

extdlgs.pas contains extended dialogs available in Lazarus Component Library (LCL) applications. It adds the following components to the Dialogs tab in the Lazarus IDE Component Palette:

  • TOpenPictureDialog
  • TSavePictureDialog
  • TCalendarDialog
  • TCalculatorDialog
TPreviewFileControl - a windowed control allowing the contents of a file to be previewed before opening.

TPreviewFileControl is a TWinControl descendant which implements a windowed control that allows the content in a file to be viewed in a TPreviewFileDialog class instance.

TPreviewFileControl is the type used to implement the PreviewFileControl property in TPreviewFileDialog.

Sets the value for the PreviewFileDialog property. New value for the property.

Overridden to ensure proper handling of the WS_CHILD flag in Style in the Parent control.

TWinControl.CreateParams TCreateParams
Creation parameters updated in the method. Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited constructor. Create sets the value for the CompStyle member (deprecated), and calls SetInitialBounds to size the control using the values returned from GetControlClassDefaultSize.

TControl.SetInitialBounds TWinControl.Create
Owner for the class instance. Dialog which created the file preview control.

PreviewFileDialog is a TPreviewFileDialog property which contains the dialog which created the file preview control. The value in PreviewFileDialog is is assigned in the CreatePreviewControl method in TPreviewFileDialog.

TPreviewFileDialog - a dialog that allows the contents of a file to be inspected before opening the file.

TPreviewFileDialog is a TOpenDialog descendant which implement a dialog used to preview and select a file on the local file system. TPreviewFileDialog extends the ancestor class with additional properties, methods, and events used to configure and execute the dialog.

TOpenDialog
Gets the value for the PreviewFileControl property.

Calls CreatePreviewControl if a TPreviewFileControl instance has not already been created for the dialog.

Value for the property. CreatePreviewControl - create an instance of the windowed control used in the dialog.

CreatePreviewControl is a procedure used to create and initialize the class instance used in the PreviewFileControl property. CreatePreviewControl create a TPreviewFileControl instance, sets its PreviewFileDialog property to the current class, and calls the InitPreviewControl method.

CreatePreviewControl is called from the DoExecute method in TPreviewFileDialog.

InitPreviewControl - initializes the windowed control created for the dialog.

InitPreviewControl is a procedure used to initialize the PreviewFileControl property used in the dialog. InitPreviewControl sets the name for the control. InitPreviewControl is called from the CreatePreviewControl method.

Creates the PreviewFileControl and displays the dialog.

DoExecute is an overridden Boolean function in TPreviewFileDialog.

DoExecute calls the CreatePreviewControl method to allocate resources for the PreviewFileControl property. It calls the inherited method to display the dialog, select a file on the local file system, and get the return value for the method. The return value is True when the dialog return value in UserChoice is mrOk.

DoExecute is called from the Execute method in the TCommonDialog ancestor class.

TCommonDialog.Execute TCommonDialog.UserChoice TOpenDialog.DoExecute
Constructor for the class instance.

Create is the overridden constructor for the class instance. Create calls the inherited constructor, and sets the value in CompStyle (deprecated) to csPreviewFileDialog.

csPreviewFileDialog
Owner of the class instance. Windowed control used to preview the contents of a file in the dialog.

PreviewFileControl is a read-only TPreviewFileControl property which contains the windowed control used to preview the contents of a file in the dialog. The resources for the property are allocated in the CreatePreviewControl method called when the dialog is executed. The property value is unassigned (contains Nil) prior to calling Execute.

TCommonDialog.Execute
TOpenPictureDialog - a preview dialog that shows a preview of a picture before opening the file.

TOpenPictureDialog is a TPreviewFileDialog descendant which implements a dialog used to preview and select image files using common image formats recognized for the platform or OS. It provides DefaultFilter and Filter properties which use file masks for file extensions supported for the TGraphic class. The ImageCtrl property provides the image preview for the dialog.

IsFilterStored - returns True if a filter is stored.

IsFilterStored is a Boolean function used to get the value for the storage specifier for the Filter property. The return value indicates if the value in Filter is included in the content read and written using the LCL component streaming mechanism. It returns True when the value in Filter is different than the value in DefaultFilter.

True when Filter is included in the LCL component streaming content. TImage used to preview the content in an image file. ImageCtrl is a read-only TImage property which contains the image used to preview the content for an image file on the local file system. PictureGroupBox - a groupbox related to a single picture ???

PictureGroupBox is a read-only TGroupBox property which provides a container for the ImageCtrl in the dialog. PictureGroupBox is assigned as the Parent for the ImageCtrl property, and provides the bounds to which the ImageCtrl is aligned. In turn, PictureGroupBox uses the PreviewFileControl as its Parent.

Initializes the PreviewFileControl for the dialog.

InitPreviewControl is overridden in TOpenPictureDialog. InitPreviewControl calls the inherited method, and ensures that PreviewFileControl is assigned as the Parent control for PictureGroupBox. InitPreviewControl is called from the inherited CreatePreviewControl method.

ClearPreview - clears the preview area.

ClearPreview is a procedure used to clear the image content and the caption displayed in the dialog. ClearPreview is called from the DoShow, DoClose, and UpdatePreview methods.

UpdatePreview - updates the preview image, implementing any pending changes.

UpdatePreview is a procedure used to update the file name and image used in the preview dialog. Please note: No actions are needed or performed in the method when FileName has the same value as PreviewFileName.

The FileName property is assigned to PreviewFileName, which is used as the source for the content displayed in ImageCtrl. FileName must be a valid file name on the local file system, and have read permissions. PreviewFileName is loaded into the picture for the ImageCtrl, and the caption in PictureGroupBox is updated to display the Width and Height for the stored image in the format '(%dx%d)'.

If the file is not successfully loaded (due to permissions or image format), the ClearPreview method is called.

UpdatePreview is called from the DoSelectionChange method when the selected file name for the preview dialog has changed.

TFileDialog.FileName
Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited constructor.

Creates sets the value in DefaultFilter to the all files mask for common image format used on the platform or OS. This value is also assigned to the Filter property for the dialog.

Create allocates resources needed for the PictureGroupBox and ImageCtrl properties, and sets their parentage, alignment, and display properties.

GraphicFilter
Owner for the class instance. Performs actions needed when the dialog is closed.

DoClose is an overridden method used to perform actions needed when the dialog is closed. DoClose calls ClearPreview to remove image content displayed in ImageCtrl and to clear the caption assigned to PictureGroupBox.

DoClose calls the inherited method to signal the OnClose event handler (when assigned).

TCommonDialog.OnClose TCommonDialog.DoClose
Performs actions needed when the selected file name for the dialog is changed.

DoSelectionChange is an overridden method used to perform actions needed when the selected file name for the dialog is changed. DoSelectionChange calls UpdatePreview to update the PreviewFileName, ImageCtrl and PictureGroupBox properties.

DoSelectionChange calls the inherited method to signal the OnSelectionChange event handler (when assigned).

TOpenDialog.OnSelectionChange TOpenDialog.DoSelectionChange
Performs actions needed to display the preview dialog in its initial state.

DoShow is an overridden procedure used to display the Picture File Open preview dialog. DoShow calls ClearPreview to set the dialog to the state needed prior to selecting an image file name in the preview dialog.

DoShow calls the inherited method to signal the OnShow event handler (when assigned).

TCommonDialog.OnShow TCommonDialog.DoShow
GetFilterExt - returns the extension for filtering filenames.

GetFilterExt is a String function used to get the file extension for the value in the Filter property. GetFilterExt parses the value in Filter, and ignores the all files mask ('*.*') in favor of actual file extensions included in the property.

The return value contains the file extension found in the Filter property. If no file extension is found in Filter, the value in DefaultExt is used as the return value.

GetFilterEx is used by the Lazarus IDE in the implementation of property editors for TGraphic and TImageList.

TFileDialog.DefaultExt TGraphic TCustomImageList
File extension found in the method, or an empty string when no extension is available. DefaultFilter - the default filename filter.

DefaultFilter is a read-only String property which provides the default value for the Filter property. DefaultFilter is populated in the Create constructor with the common image formats supported for the platform or OS. Its value is assigned as the default value for the Filter property in the constructor.

GraphicFilter
Contains a delimited list of descriptions and extensions for file available in the dialog.

Filter is a String property which contains a delimited list of file name filters available in the dialog. Each value in the delimited list is separated by a Pipe (or vertical bar) character ('|') and consists of a description and file extension for files matching the filter value.

The initial value for Filter is assigned in Create using the value from the DefaultFilter property.

Use GetFilterExt to get the file extension for the current Filter value selected in the dialog. Use FilterIndex to determine the position for the selected file filter.

TFileDialog.Filter TFileDialog.FilterIndex
TSavePictureDialog - a dialog for saving the picture in the current buffer to a file.

TSavePictureDialog is a TOpenPictureDialog descendant which implements a dialog used to save a picture to a file. TSavePictureDialog provides the same preview capabilities implemented in ancestor classes, and provides an overridden DefaultTitle method to set the title displayed in the dialog.

Gets the default value for the Title property.

DefaultTitle is an overridden String function in TSavePictureDialog. It returns the value in rsfdFileSaveAs as the Title used for the dialog. DefaultTitle is used in the constructor in TCommonDialog to set the value for its Title property.

TOpenDialog.DefaultTitle TCommonDialog.Create TCommonDialog.Title rsfdFileSaveAs
Default value for the Title property. Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited constructor. Create sets the value in the FCompStyle member (deprecated) to the value csSaveFileDialog.

Owner of the class instance. The common base class for custom drawn dialogs (Calculator and Calendar).

TExtCommonDialog is a TCommonDialog descendant which implements a common base class for custom drawn dialogs such as TCalculatorDialog and TCalendarDialog. It provides additional properties used to set the position for the form displayed in the dialog.

TCommonDialog
Gets the value for the Left property. Value for the property. Gets the value for the Height property. TCommonDialog.GetHeight Value for the property. Gets the value for the Top property. Value for the property. Gets the value for the Width property. TCommonDialog.GetWidth Value for the property. Sets the value for the Left property. New value for the property. Sets the value for the Top property. New value for the property. Contains the form displayed modally for the custom-drawn dialog.

DlgForm is a TCustomForm property which contains the form displayed with the content for the custom-drawn dialog.

The value in DlgForm is assigned in descendent classes to use the form type required for the dialog. Changes to values in the Top, Left, and DialogPosition properties are applied to the corresponding properties in DlgForm.

Constructor for the class instance. Create is the overridden constructor for the class instance, and calls the inherited method. Create sets the default value for the DialogPosition property to poMainFormCenter. TPosition CommonDialog.Create Owner of the class instance. Destructor for the class instance. TLCLComponent.Destroy Contains the left coordinate for the dialog form.

Left is an Integer property which contains the client coordinate for the left-hand edge of the dialog. Read and write access for the property value are redirected to the Left property in DlgForm (when assigned).

Use the Top property to access the coordinate for the top edge of the dialog.

Contains the top coordinate for the dialog form.

Top is an Integer property which contains the client coordinate for the top edge of the dialog. Read and write access for the property value are redirected to the Top property in DlgForm (when assigned).

Use the Left property to access the coordinate for the left-hand edge of the dialog.

Specifies the position where the dialog is displayed.

DialogPosition is a TPosition property which specifies the position where the dialog is displayed. The default value for the property is poMainFormCenter, and indicates that the dialog is centered both horizontally and vertically on the main form for the application.

See TPosition for more information about the values in the enumeration and their meanings.

The value in DialogPosition is used in descendent classes when the dialog is Executed.

TPosition
Implements a pop-up calculator dialog used to perform simple calculations and return the value.

TCalculatorDialog is a TExtCommonDialog descendant which implements a pop-up calculator dialog used to perform calculations and return the result in the Value property. Value uses the Double type, and can be represented using the number of digits in the Precision property.

TCalculatorDialog uses a TCalculatorForm instance in the DlgForm property which includes separate panels to display the input value, numeric keys, labels, and other buttons on the dialog form. A CalculatorLayout property allows use of a detailed or a simplified view on the form. Properties are provided to set the colors used for components on DlgForm, including:

  • ColorBtnDigits
  • ColorBtnMemory
  • ColorBtnOk
  • ColorBtnCancel
  • ColorBtnClear
  • ColorBtnOthers
  • ColorDisplayText
  • ColorDisplayBack

Use the Memory property to store or retrieve a value for the calculator dialog.

TCalculatorForm
Gets the value for the CalcDisplay property.

GetDisplay is a Double function used to get the display value from the form instance in DlgForm. If DlgForm has not been assigned, the Value property is used as the return value for the method.

Value for the property. Sets the value for the DialogScale property. New value for the property. Implements the event handler signalled when the dialog is closed.

OnDialogClose implements the event handler signalled when the dialog form is closed. OnDialogClose calls the DoClose method to execute the OnClose event handler (when assigned).

OnDialogClose is assigned as the OnClose event handler for the form in DlgForm in the Execute method.

TCommonDialog.OnClose TCommonDialog.Execute
Object for the event notification. Action performed to close the dialog. Implements the event handler signalled when the dialog is displayed.

DialogShow implements the event handler signalled when the dialog form is displayed. DialogShow calls the DoShow method to signal the OnShow event handler (when assigned).

DialogShow is assigned as the OnShow event handler for the form in DlgForm in the Execute method.

TCommonDialog.OnShow
Object for the event notification. Implements the event handler signalled to determine if the dialog can be closed.

DialogCloseQuery implements the event handler signalled to determine if the dialog can be closed. DialogCloseQuery sets the value in the UserChoice property to the modal result returned by the dialog form in DlgForm. It calls DoCanClose to signal the OnCanClose event handler (when assigned).

DialogCloseQuery is assigned as the OnCloseQuery event handler for the form in DlgForm in the Execute method.

TCommonDialog.Execute TCommonDialog.OnCanClose
Object for the event notification. True when the dialog can be closed. Change - software emulator for the OnChange event ???

Change is a procedure used to perform actions needed when the dialog has been changed. Change signals the OnChange event handler (when assigned).

Implements the event handler signalled to process keys in the dialog.

CalcKey is a procedure which implements the event handler signalled to process keys in the dialog. CalcKey signals the OnCalcKey event handler (when assigned).

CalcKey is assigned as the OnCalcKey event handler for the TCalculatorForm instance created in the Execute method.

Key examined in the event handler. Gets the default value used in the Title property for the calculator dialog.

DefaultTitle is an overridden String function which gets the default value used in the Title property for the calculator dialog. The return value is set to the rsCalculator resource string in TCalculatorDialog.

The value from DefaultTitle is assigned to the Title property in the constructor for the class instance.

TCommonDialog.Title TCommonDialog.Create TCommonDialog.DefaultTitle
Default value for the Title property. Implements the event handler signalled when the calculator display has been changed on the dialog form.

DisplayChange signals the OnDisplayChange event handler (when assigned) to perform actions needed for the update. DisplayChange is used as the handler routine for the OnDisplayChange property in TCalculatorForm. It is assigned when the calculator form instance is created and configured in the Execute method. It allows the dialog form to notify the dialog component when its calculator panel has been updated.

Constructor for the class instance.

Create is the overridden constructor for the TCalculatorDialog class. It calls the inherited method on entry, and sets the default values for properties including:

  • Precision
  • BeepOnError
  • DialogScale
  • CalculatorLayout
  • ColorBtnDigits
  • ColorBtnOthers
  • ColorBtnMemory
  • ColorBtnOk
  • ColorBtnCancel
  • ColorBtnClear
  • ColorDisplayText
  • ColorDisplayBack
Owner of the class instance. Destructor for the class instance.

Destroy is the overridden destructor for the TCalculatorDialog class. Destroy frees references to handler routines assigned to the OnChange and OnDisplayChange properties. It calls the inherited method prior to exit.

Creates, configures, and displays the form for the calculator dialog.

Execute is an overridden Boolean function used to create, configure, display, and capture the result from the form for the calculator dialog. Execute calls CreateCalculatorForm to create the TCalculatorForm in the DlgForm property, and sets the event handlers for the form to methods defined in the class instance. For example:

DlgForm.OnCalcKey
Set to the CalcKey method
DlgForm.OnDisplayChange
Set to the DisplayChange method
DlgForm.OnShow
Set to the DialogShow method
DlgForm.OnClose
Set to the DialogClose method
DlgForm.OnCloseQuery
Set to the DialogCloseQuery method

When DialogScale contains any value other than 100, the scaling percentage is applied to DlgForm.

The value in DialogPosition is stored in DlgForm as well. At design-time, the dialog position is always aligned to the center of the screen (or current monitor). When DialogPosition is poDesigned, the form coordinates in DlgForm are set to the values in the Left and Top properties. The content stored in the Title, Memory, Precision, and Value properties are copied into the corresponding properties in DlgForm.

Execute calls the ShowModal method in DlgForm to display the modal calculator dialog form. The return value for the method is set to True when the modal result from the form is mrOk. When the result is True, the Memory and Value properties are updated with the values form the dialog form. The Change method is called when the Value property has been altered.

The coordinates for the form are captured on exit, and stored in the Left and Top properties. The dimensions for the form (Width and Height) are also stored.

Execute frees the resources allocated to the DlgForm property prior to exit from the method.

CreateCalculatorForm TCalculatorForm TCommonDialog.Execute
True when the modal result for the form is mrOk. CalcDisplay - the current numeric value in the main calculator display.

CalcDisplay is a read-only Double property which contains the current numeric value for the calculator. The property value is read from the TCalculatorForm instance in DlgForm when it has been assigned. Otherwise the content stored in Value is used as the property value.

TCalculatorForm
Memory - the value stored in the calculator's memory.

Memory is a read-only Double property which contains the numeric value stored using the Memory button on the calculator dialog. The value in Memory is passed to the form in DlgForm in the Execute method, and updated when the modal result for the calculator form is mrOk.

TCalculatorForm
BeepOnError - if True, beeps when there is an entry error or other calculator error.

BeepOnError is a Boolean property which indicates if a beep occurs when an error occurs in the calculator dialog. The default value for the property is True. The value in BeepOnError is assigned to the corresponding property in DlgForm in the Execute method.

TCalculatorForm
CalculatorLayout - whether simple or normal.

CalculatorLayout is a TCalculatorLayout property which specifies the layout used for the calculator dialog form in DlgForm. CalculatorLayout is passed as an argument to the CreateCalculatorForm routine in Execute, and determines the size and position for the panels and buttons on the form.

clNormal
Buttons and panels use a larger size with more whitespace
clSimple
Buttons and panels use a more compact size with less whitespace

The default value for the property is clNormal.

TCalculatorLayout CreateCalculatorForm
Precision - the level of precision to be used in calculations; default is set by DefCalcPrecision.

Precision is a Byte property which indicates the number of precision digits used when formatting the display for the Value property. Precision is assigned to the dialog form in DlgForm, and passed as an argument when calling the FloatToStrF routine.

The default value for the property is determined by the CalcDefPrecision constant.

TCalculatorForm CalcDefPrecision FloatToStrF
Value - the numeric value (result) returned by the calculator.

Value is a Double property which contains the numeric value passed to and returned from the calculator dialog form. Value is assigned to the TCalculatorForm instance in DlgForm in the Execute method, and updated when the modal result for the form is mrOk.

Value is used as the value for the CalcDisplay property when the dialog form in DlgForm has not been assigned (contains Nil).

TCalculatorForm
OnCalcKey - event handler for a key press in the calculator.

OnCalcKey is a TKeyPressEvent property used as the event handler for key press events in the calculator dialog form. OnCalcKey is signalled from the CalcKey method which is assigned as the OnCalcKey event handler in DlgForm.

Applications must implement an object procedure using the signature in TKeyPressEvent to respond to the event notification.

TCalculatorForm.OnCalcKey TKeyPressEvent
OnChange - event handler for any change in the calculator.

OnChange is a TNotifyEvent property used as the event handler signalled when the value for the calculator dialog is changed. OnChange is signalled from the Change method when the calculator dialog returns a modified value for the Value property.

Applications must implement an object procedure using the signature in TNotifyEvent to respond to the event notification.

TCalculatorForm TNotifyEvent
OnDisplayChange - event handler for any change in the calculator display. OnDisplayChange is a TNotifyEvent property used as the event handler signalled when the display value for the calculator dialog is changed. OnDisplayChange is signalled from the DisplayChanged method which is assigned as the OnDisplayChange event handler in DlgForm. TCalculatorForm.OnDisplayChange TNotifyEvent Scaling percentage applied to the calculator dialog form.

DialogScale is an Integer property which indicates the scaling percentage applied to the height and width for the calculator dialog. When the value for the property is changed, it its validated and adjusted to ensure that it is in the range 80...400 (the minimum and maximum allowed for the property).

DialogScale is passed as the multiplier argument to the ScaleBy method in TCalculatorForm; the divisor is always set to 100.

The default value for the property is 100, and indicates that the dialog is displayed at 100% of its designed size.

Color for the digit buttons displayed in the calculator dialog. Color for the Memory button displayed in the calculator dialog. Color for the OK button displayed in the calculator dialog. Color for the Cancel button displayed in the calculator dialog. Color for the Clear button displayed in the calculator dialog. Color for other buttons displayed in the calculator dialog. Color for text displayed in the calculator dialog. Color for background in the display area for the calculator dialog. TCalendarDialog - a popup calendar dialog that allows a date to be selected and returned to the main program.

TCalendarDialog is a TExtCommonDialog descendant which implements a calendar dialog used to select a date from a TCalendar control. It provides a Date property that contains the date used when selecting a date using the Calendar control displayed in the dialog.

TCalendarDialog creates and configures a TForm instance that is displayed in the Execute method for the dialog. The form uses the Title, DialogPosition, DisplaySettings, and Date properties assigned in the class. A new TCalendar control is created for the form, and stored in the Calendar property. Methods which implement the event handlers for the calendar control are also assigned. The form instance is displayed modally, and the modal result is captured in the UserChoice property. Date is updated when a calendar date is selected while the form is active.

TCalendar
Implements the event handler signalled when the dialog form is closed.

DialogClose calls the DoClose method to signal the OnClose event handler (when assigned).

DialogClose is assigned to the OnClose event handler for the dialog form created in the Execute method.

See DialogCloseQuery for the handler routine used in the OnCloseQuery event handler for the dialog form.

TCustomForm.OnClose
Object instance for the event notification. Not used in TCalendarDialog. Action to perform when the dialog is closed. Not used in TCalendarDialog. Implements the event handler signalled to determine if the dialog form can be closed.

DialogCloseQuery copies the value from the ModalResult property to the UserChoice property in the dialog component.

The CanClose argument is a variable parameter which contains True if the form can be closed. It is passed as an argument to the DoCanClose method where the OnCanClose event handler is signalled (when assigned) to get its return value. OnCanClose should set CanClose to False to prevent closing the form.

DialogCloseQuery is assigned to the OnCloseQuery event handler for the dialog form created in the Execute method.

See DialogClose for the actions performed when the form is actually closed.

TCommonDialog.UserChoice TCustomForm.OnCloseQuery
Object instance for the event notification. Not used in the method. Returns the value from the OnCanClose event handler. Implements the event handler signalled when the dialog form is displayed. Object instance (TForm) for the event notification. Implements the event handler signalled when the day number in Date is changed. Object instance (TForm) for the event notification. Implements the event handler signalled when the month in Date is changed. Object instance (TForm) for the event notification. Implements the event handler signalled when the year in Date is changed. Object instance (TForm) for the event notification. Event handler used to signal the OnChange event when the Calendar is updated. Object instance (TForm) for the event notification. Gets the date value from the Calendar on the dialog form.

GetNewDate is a procedure used to get the date value from the TCalendar control on the dialog form. It assigns the DateTime value from the calendar control to the Date property in the dialog component.

GetNewDate is called from methods like CalendarDblClick, CalendarDayChanged, CalendarYearChanged, and CalendarMonthChanged. It is assigned as the OnClick event handler for the OK button displayed on the calendar dialog form.

Object instance for the event notification. Not used in the method. Implements the event handler signalled for a double click on the calendar control in the dialog.

CalendarDblClick is the handler routine assigned to the OnDblClick event in the TCalendar instance for the dialog form. It ensures that the value in Date is updated when a mouse double click occurs on a date in the TCalendar control on the dialog form. GetNewDate is called to update the value in Date. The calendar dialog form is updated to set its ModalResult value to mbOK.

TCalendar.OnDblClick
Object instance (TForm) for the event notification. Gets the default value for the Title property used as the Caption for the calendar dialog form.

The return value is set to the content in the rsPickDate resource string.

Default value for the Title property. Constructor for the class instance.

Create is the overridden constructor for the TCalendarDialog class. It calls the inherited method entry which sets the value in DialogPosition to poMainFormCenter. Create sets the default values for properties including:

DisplaySettings
Set to the value in the DefaultDisplaySettings constant.
Date
Set to the date part of the value from the Now function.
OKCaption
Set to the value in the rsMbOK resource string.
CancelCaption
Set to the value in the rsMbCancel resource string.
Owner of the class instance. Creates and displays the form for the calendar dialog, and captures the results.

Execute is an overridden method in TCalendarDialog. It creates and configures a new TForm instance displayed for the dialog component. The dialog form includes controls needed to select a date value, and to accept or reject the selected value. This includes:

  • TCalendar
  • TButton instances for the OK and Cancel buttons.

Values from properties in the class instance are used to configure the dialog form, including:

Title
Used as the Caption for the dialog form.
DialogPosition
Sets the Position property in the form instance at run-time. At design-time, the dialog is centered on the screen.
DisplaySettings
Sets the display settings used for the TCalendar instance on the dialog form.
Date
Sets the initial value for DateTime in the TCalendar instance on the dialog form.

Methods in the class instance are assigned to the event handlers for the dialog form and its controls, including:

DialogShow
Assigned to the OnShow event handler in the dialog form.
DialogClose
Assigned to the OnClose event handler in the dialog form.
DialogCloseQuery
Assigned to the OnCloseQuery event handler in the dialog form.
CalendarDayChanged
Assigned to the OnDayChanged event handler in the TCalendar instance on the form.
CalendarMonthChanged
Assigned to the OnMonthChanged event handler in the TCalendar instance on the form.
CalendarYearChanged
Assigned to the OnYearChanged event handler in the TCalendar instance on the form.
CalendarChange
Assigned to the OnChange event handler in the TCalendar instance on the form.
CalendarDblClick
Assigned to the OnDblClick event handler in the TCalendar instance on the form.

The ShowModal method for the dialog form is called to display the form and capture the return value. The return value is True if the ModalResult value is mrOK (when the OK button was clicked). The return value is False if the Cancel button was clicked or the form was closed using the window decoration.

The date selected using the calendar control is stored when the CalendarChange routine is executed (via TCalendar.OnChange). This causes the OnChange event handler in the class instance to be signalled to store the updated value.

The form is freed prior to exiting from the method.

TCommonDialog.Execute
True if the OK button was used to close the dialog form. Contains the left coordinate for the dialog.

Used when Position contains poDesigned. Otherwise, it is updated after the form is dynamically created, aligned, and displayed.

Contains the top coordinate for the dialog.

Used when Position contains poDesigned. Otherwise, it is updated after the form is dynamically created, aligned, and displayed.

The selected Date for the calendar dialog.

Date is a TDateTime property which contains the date displayed and updated using the form for the dialog. The initial value in Date is set in the Create constructor to the date returned from the Now function. The property is updated in the GetNewDate method when a new month, day, or year is selected using the calendar control on the dialog form.

This is not the standard RTL Date function.

The user-specified settings determining the appearance of the calendar on the dialog.

DisplaySettings contains the user-specified settings which determine the appearance for the calendar displayed in the dialog.

DisplaySettings is a set type which may contain zero or more settings. Possible values include: ShowHeadings,ShowDayNames, NoMonthChange, ShowWeekNumbers.

Event handler signalled when the day number in Date has been changed. Event handler signalled when a month number in Date has been changed.

OnMonthChanged is an event handler signalled when the value for the Month in the Date is changed.

Event handler signalled when the year number in Date has been changed. Event handler signalled when the value in Date has been changed. Caption displayed on the OK button.

OKCaption is a String property which contains the caption displayed on the OK button in the dialog.

Caption displayed on the Cancel button for the calendar dialog form.

CancelCaption is a String property which contains the caption displayed on the Cancel button for the dialog.

Registers components in the unit for use in the Lazarus IDE.

Register is a procedure used to register components in the extdlgs.pas unit for use in the Lazarus IDE. Register adds the TOpenPictureDialog, TSavePictureDialog, TCalendarDialog, and TCalculatorDialog components to the 'Dialogs' tab in the Lazarus IDE.