Contents Screen

TAdrockCalendarEdit

Version 1.07, 3 October, 1995

Click here for Properties	Click here for Methods	Click here for Events

Unit

AdCalBtn

Registration

Registration of this control is available on-line via the CompuServe SWREG forum #7605 for $12.00 US.

Please contact us at  CompuServe 100353,110 or Internet: DHMCC@IBM.NET.

Please set your subject line to TADROCKCalendarEdit for all correspondence regarding this component.

Include your name, EMAIL or physical address and Visa Number and Expiry Date if ordering directly.

There is a complete description of the component below

Description

Use a TAdrockCalendarEdit component to put an enhanced edit control on your form. The TAdrockCalendarEdit control is used to retrieve date information from the end user.

The edit control will input the date in the format used the windows short date format. If your windows short date format is D/M/YY  then the control will accept the date only in that order, if it is M/D/YY then the date control will accept in that order.

The edit control inputs data depending on the property of Alignment

The edit control will display the date when the edit control has the focus using the Windows Short Date format.

When the edit control does not have the focus it will display the date in the date property depending on the property DisplayDateFormat. DisplayDateFormat can contain any format supported by the standard delphi function FormatDateTime(). By default it is the Windows Short Date Format.

There is a calendar function contained within the control that will open up a calendar just below the control or if it will not fit, then just above the control. The user can then select the date required either by Mouse or Keyboard movements.

Alt-Down arrow is the keystroke command to open and close the controls calendar when the edit control has the input focus. This command can be disabled if required through the property AllowAltDown.

The edit control has a small button that is displayed on the right side of the edit control. This button will display a glyph of an arrow like combo boxes, a calendar glyph, a date glyph, nothing, or a user defined glyph file. The end user can click the button with the mouse to open the calendar, or just Alt-Down arrow. The button can be set to only be visible while the edit control has the focus, or to have the button displayed all the time the form is displayed, or not to show the button at all.

You can insert the current date into the edit control by pressing Ctrl-SemiColon (Ctrl-;). You can disable the inserting of the current date through AllowCtrlSemi.

While the calendar is open, you may type into the edit control  to set the date, you may select another control on the form, and you can tab off the control.

The date of the control can be set by setting the DATE property, this is a Read/Write property and can be set when the control has or has not got the focus.

The calendar that opens can be customized by settings the following color properties, color of the dates on the calendar, color of the selected date on the calendar days, color of the days Mon-Fri, color of day Saturday, Color of day Sunday, Color of the selected date title, Date format displayed on the calendar.

The calendar will attempt to open at the bottom of the edit control, if there is enough room to display it, if not it will open above the edit control. If there is not enough room to display the calendar to the right, it will move to the left to allow the calendar to open fully.

Note	Example when the calendar is open.
Because the calendar is in fact a custom control, the calendar can not be displayed outside of the current form. Therefore if you have a very small form (Smaller than the calendar when opened), the calendar will only display as much as can fit in a form. This should not cause any problems as this is how all components work.


TAdrockCalendarEdit

The TAdrockCalendarEdit control is a data aware edit control that provides the ability to limit input to valid dates, select dates from a popup calendar and numerous other date features.

You can open and close the calendar with either  the Alt-Down arrow, or with the mouse clicking on the edit controls button.

The edit control is a very easy way to allow end users to enter dates, as you can type values in directly even while the calendar is displayed.

The edit control has been designed to be used as a data edit control, but the control also is designed to work as a standard edit control not linked to a data source.

For more features and the contents page click here


Properties

This is the properties page TAdrockCalendarEdit, please select the property.

Alignment	AllowCtrlSemi	AllowAltDown
AllowSpeedKeys	AppendDateFormat	AutoSelect
AutoSize	BadDateMessage	BorderStyle
ButtonGlyph	ButtonGlyphFileSpec	ButtonHint
CalendarDateFormat	CalendarHint	Color
ColorHighlight	ColorMonFri	ColorMonth
ColorNormal	ColorSaturday	ColorSunday
Ctl3D	Cursor	DataField
DataSource	Date	Date Bevel
DisplayDateFormat	DragCursor	DragMode
EditDateFormat	EditHint	Enabled
Font	height	HelpContext
HideSelection	Hint	Language
Left	MaxLength	Name
ParentColor	ParentCtl3d	ParentFont
ParentShowHint	PopupMenu	ReadOnly
Required	RequiredFieldMessage	ShowBadAtCalOpen
ShowButton	ShowButtonHint	ShowCalendarHint
ShowDateOnCalendar	ShowEditHint	ShowHint
ShowWeekNumbers	StartOfWeek	TabOrder
TabStop	Tag	Text
Top	Version	Visible
Width


Methods

AsString

AsDateTime


Events

This is the events page TAdrockCalendarEdit, please select the event.

OnButtonClick

OnCalendarPickDate


AsString

This method will return the date as a string. It is basically the same as DateToStr(TAdrockCalendarEdit.Date)

Example:

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

     ShowMessage('The date in the TAdrockCalendarEdit is '+AdrockCalendarEdit1.AsString);

end;


AsDateTime

This method will return the date as a TDateTime object. It is basically the same as TAdrockCalendarEdit.Date

Example:

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

     if (AdrockCalendarEdit1.AsDateTime = Date) then

        ShowMessage('The date you entered is today''s date')

     else

        ShowMessage('The date you entered is not today''s date');

end;


OnButtonClick

This event gets triggered when the user clicks the button to open or close the calendar.


OnCalendarPickDate

This event gets triggered when the user picks a date when the calendar is open.


Date

Applies to

TAdrockCalendarEdit components

Declaration

property Date: TDateTime;

Description

The Date property either sets or gets the current date. if you set the date then the control updates its display to reflect the change.

If the edit field is linked to a DataField then the DataSource is put into edit mode and the control is updated to reflect the new date.

You can read the Date property at any time to retrieve the current date that the edit control has.

Example

Uses SysUtils; { For Date }

AdrockCalendar3d1.Date := Date;

Set the edit field to the todays date.


EditDateFormat

Applies to

TAdrockCalendarEdit components

Declaration

property EditDateFormat: TAdrockCalendarEditDateFormat

Description

This property has two values df2DigitYears and df4DigitYears.  You use these properties to set the input format mode for the control.

Df2DigitYears will use the standard windows short date format to input the date which can introduce problems if you want to use a century other than the 19th . If you do enter a date in df2DigitYears that contains a century the century part will default to 19. The only way to stop this error is by using the df4DigitYear format.

Df4DigitYears also uses the Windows Short Date Format but makes sure that the year is always 4 digits. You do not get century problems when using this mode. The only change is the end user must edit existing dates with 4 digit years. I think this outweighs loosing any details.

Example of the problem:

If the user types this Date in the control.	If you check the .DATE property when using df2DigitYears it will contain.	If you check the .DATE property when using df4DigitYears it will contain.
20/12/1866	20/12/1966	20/12/1866
20/12/66	20/12/1966	20/12/1966
20/12/05	20/12/1905	20/12/1905
20/12/2005	20/12/1905	20/12/2005
Note:	The 2 digit  mode is only usable for dates in the 19th century. The TAdrockCalendarEdit component analyses what the user has typed in at various times. If the display only shows 2 digits then it is assumed to be in the 19th century. We use standard delphi routines to convert dates and that is how they work.

Use the 4Digit Mode, it is a lot safer, and you will NEVER get these century errors….


AllowAltDown

Applies to

TAdrockCalendarEdit components

Declaration

property AllowAltDown: Boolean;

Description

If the AllowAltDown property is set to FALSE then the user can not open the calendar by pressing Alt-Down arrow.

If the AllowAltDown property is set to TRUE then the user can open the calendar by pressing Alt-Down arrow.

Notes

If there is an invalid date entered when the user presses Alt-DownArrow then the component will state this and default to todays date when the calendar is displayed.


AllowCtrlSemi

Applies to

TAdrockCalendarEdit components

Declaration

property AllowCtrlSemi: Boolean;

Description

If the AllowCtrlSemi property is set to TRUE then the user can use Ctrl-semicolon to insert the current date into the control overriding the existing date.

If the AllowCtrlSemi property is set to FALSE then the user can not use Ctrl-semicolon to insert the current date into the control.


AllowSpeedKeys

Applies to

TAdrockCalendarEdit components

Declaration

property AllowSpeedKeys: Boolean;

Description

If the AllowSpeedKeys property is set to TRUE then the user can move to the previous and next dates using the + and - keys. If the control is empty and pressing + will show tomorrows date, likewise if the control is empty and pressing - will show yesterdays date.

If the AllowSpeedKeys property is set to FALSE then the user can not move forward or backwards with the + and - Keys

Notes

If there is an invalid date entered when the user presses the + or - keys then the component will state this and will not update the date.


CalendarDateFormat

Applies to

TAdrockCalendarEdit components

Declaration

property CalendarDateFormat : String;

Description

This property controls the way the selected date is displayed when the calendar is being displayed. By default the format is the Short Windows Format, but you can supply any format supported by the standard Delphi function FormatDateTime().

Examples

D MMM, YYYY	5 Mar, 1995
DD MMM, YYYY	05 Mar, 1995
D MMMM, YYYY	5 March, 1995
D/M/YY	5/3/95
M/D/YY	3/5/95

See Also Display Formats


DisplayDateFormat

Applies to

TAdrockCalendarEdit components

Declaration

property DisplayDateFormat : String;

Description

This property controls the way the date is displayed when the control does not have the input focus. By default the format is the Short Windows Format, but you can supply any format supported by the standard Delphi function FormatDateTime().

Examples

D MMM, YYYY	5 Mar, 1995
DD MMM, YYYY	05 Mar, 1995
D MMMM, YYYY	5 March, 1995
D/M/YY	5/3/95
M/D/YY	3/5/95

See Also Display Formats


DisplayFormatsSupported
Formats supported by DisplayDateFormat & CalendarDateFormat

Specifier	Displays

c	Displays the date using the format given by the ShortDateFormat global variable, followed by the time using the format given by the LongTimeFormat global variable. The time is not displayed if the fractional part of the DateTime value is zero.

d	Displays the day as a number without a leading zero (1-31).

dd	Displays the day as a number with a leading zero (01-31).

ddd	Displays the day as an abbreviation (Sun-Sat) using the strings given by the ShortDayNames global variable.

dddd	Displays the day as a full name (Sunday-Saturday) using the strings given by the LongDayNames global variable.

ddddd	Displays the date using the format given by the ShortDateFormat global variable.

dddddd	Displays the date using the format given by the LongDateFormat global variable.

m	Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mm	Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mmm	Displays the month as an abbreviation (Jan-Dec) using the strings given by the ShortMonthNames global variable.

mmmm	Displays the month as a full name (January-December) using the strings given by the LongMonthNames global variable.

yy	Displays the year as a two-digit number (00-99).

yyyy	Displays the year as a four-digit number (0000-9999).

/	Displays the date separator character given by the DateSeparator global variable.

'xx'/"xx"	Characters enclosed in single or double quotes are displayed as-is, and do not affect formatting.

Format specifiers may be written in upper case as well as in lower case letters--both produce the same result.

If the string given by the Format parameter is empty, the date and time value is formatted as if a 'c' format specifier had been given.

Examples

D MMM, YYYY	5 Mar, 1995
DD MMM, YYYY	05 Mar, 1995
D MMMM, YYYY	5 March, 1995
D/M/YY	5/3/95
M/D/YY	3/5/95


CalendarHint

Applies to

TAdrockCalendarEdit components

Declaration

property CalendarHint : String;

Description

This property controls the text to display when a hint is displayed for the calendar. The hint is only for the calendar and is only displayed if ShowCalendarHint is set to true.


Language

Applies to

TAdrockCalendarEdit components

Declaration

property Language : TAdrockLanguage;

Description

Note:	This property is now longer used, but is left for compatibility reasons.

To allow for international support please look In the Delphi Help under Date Formatting Constants.

Below is an example of how to set International Date Name Support. When you set the variables as below the Delphi  function FormatDateTime will then use the new WeekDay and Month Names that you supplied instead of the English ones. Basically you are overwriting the English Names.

You only need to set this code once in each program you write. The FormCreate on the first form opened is a good place to put it.

This example is for SWEDISH Weekday and Month names….

procedure TForm1.FormCreate(Sender: TObject);

begin

   { Set the Short Day Names to Swedish }

   ShortDayNames[1] := 'SöX';  { X should be the 3rd letter in the week day name    }

   ShortDayNames[2] := 'MåX';  { We do not know Swedish so could not put it in here }

   ShortDayNames[3] := 'TiX';

   ShortDayNames[4] := 'OnX';

   ShortDayNames[5] := 'ToX';

   ShortDayNames[6] := 'FrX';

   ShortDayNames[7] := 'LöX';

   { Set the Long Day Names to Swedish }

   LongDayNames[1] := 'SöXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[2] := 'MåXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[3] := 'TiXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[4] := 'OnXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[5] := 'ToXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[6] := 'FrXXXXXX';  { XXXXX should be the rest of the weekday name }

   LongDayNames[7] := 'LöXXXXXX';  { XXXXX should be the rest of the weekday name }

   { Set the short month names to Swedish }

   ShortMonthNames[5]  := 'Maj';  { Since it looks like only May (English) is different you

    only need to set this one variable for Short Month Names }

   { Set the Long month names to Swedish }

   LongMonthNames[1]  := 'Januari';

   LongMonthNames[2]  := 'Februari';

   LongMonthNames[3]  := 'Mars';

   LongMonthNames[4]  := 'April';

   LongMonthNames[5]  := 'Maj';

   LongMonthNames[6]  := 'Juni';

   LongMonthNames[7]  := 'Juli';

   LongMonthNames[8]  := 'Augusti';

   LongMonthNames[9]  := 'September';

   LongMonthNames[10] := 'October';

   LongMonthNames[11] := 'November';

   LongMonthNames[12] := 'December';

end;

Below is how the calendar looks without any modifications to the date variables.	Below is how the calendar looks with the date settings set to Swedish using the code above.


ShowCalendarHint

Applies to

TAdrockCalendarEdit components

Declaration

property ShowCalendarHint : Boolean;

Description

This property controls the way the date is displayed when the control does not have the input focus. By default the format is the Short Windows Format, but you can supply any format supported by the standard Delphi function FormatDateTime().


ShowWeekNumbers

Applies to

TAdrockCalendarEdit components

Declaration

property ShowWeekNumbers: Boolean;

Description

This property controls if week numbers are shown on the calendar. This is a new property added in V1.04, it is disabled by default.

When ShowWeekNumbers = FALSE	When ShowWeekNumbers = TRUE [image].


ShowButton

Applies to

TAdrockCalendarEdit components

Declaration

property ShowButton : TAdrockShowButtonMode;

Description

This property controls the way the button is displayed in the edit control.

sbNone 	- Never show the button on the edit control, the edit control looks like a standard edit control.

sbAlways	- Show the button always, even if the focus is lost.

sbFocused	- Show only when the edit control has the focus, and remove the button when focus is lost.


ShowButtonHint

Applies to

TAdrockCalendarEdit components

Declaration

property ShowButtonHint : Boolean;

Description

You can display a hint for the button by setting this property and also setting the property ButtonHint. When the mouse is moved over the button the button hint will be displayed.


ButtonHint

Applies to

TAdrockCalendarEdit components

Declaration

property ButtonHint : String;

Description

This property controls the text to display when a hint is displayed for the button. The hint is only for the button and is only displayed if ShowButtonHint is set to true.


EditHint

Applies to

TAdrockCalendarEdit components

Declaration

property EditHint : String;

Description

This property controls the text to display when a hint is displayed for the edit control. The hint is only for the edit control, not the button or calendar and is only displayed if ShowEditHint is set to true.


ReadOnly

Applies to

TAdrockCalendarEdit components

Declaration

property ReadOnly : Boolean;

Description

If the ReadOnly property is true then you can not type into the edit field, set the date of the edit field by setting the date property and you can not open the calendar although the button will still simulate a click visually.

Note

If you have the control linked to a data field and no data source, a datasource and no data field, or the table that the datasource and datafield are linked to is closed, then the control appears to be act like readonly mode.


DataSource
DataSource & DataField

Applies to

TAdrockCalendarEdit components

Declaration

property DataSource : TDataSource;

property DataField     : TDataField;

Description

These two properties will enable the edit control to be linked to a database field, and to view and update the field details.

Note

If you have the control linked to a data field and no data source, a datasource and no data field, or the table that the datasource and datafield are linked to is closed, then the control appears to be act like the control has the readonly property set.


DataField
DataSource & DataField

Applies to

TAdrockCalendarEdit components

Declaration

property DataSource : TDataSource;

property DataField     : TDataField;

Description

These two properties will enable the edit control to be linked to a database field, and to view and update the field details.

Note

If you have the control linked to a data field and no data source, a datasource and no data field, or the table that the datasource and datafield are linked to is closed, then the control appears to be act like the control has the readonly property set.


ShowEditHint

Applies to

TAdrockCalendarEdit components

Declaration

property ShowEditHint : Boolean;

Description

You can display a hint for the edit control by setting this property and also setting the property EditHint. When the mouse is moved over the edit field  the edithint will be displayed.


Required

Applies to

TAdrockCalendarEdit components

Declaration

property Required : Boolean;

Description

If Required=TRUE then this property will force the user to enter a date into the control before it will allow then to exit.

If Required=FALSE then the user can move off the edit control even if there is no date entered.

A blank date is equal to a date of 0, or 0/0/0000


StartOfWeek

Applies to

TAdrockCalendarEdit components

Declaration

property StartOfWeek : TAdrockStartofWeek;

Description

If StartOfWeek=swSunday then when the calendar is displayed Sunday will be the start of the week, and Saturday will be the end of the week.

If StartOfWeek=swMonday then when the calendar is displayed Monday will be the start of the week, and Sunday will be the end of the week.


DateBevel

Applies to

TAdrockCalendarEdit components

Declaration

property DateBevel : TPanelBevel;

Description


ButtonGlyph

Applies to

TAdrockCalendarEdit components

Declaration

property ButtonGlyph : TAdrockGlyphMode;

Description

This property controls the way a glyph is displayed on the button.

bgNone	Do not show a glyph on the button at all just leave blank .
bgArrow	Show a glyph of a arrow, like the standard combo boxes.
bgArrow95	Show a glyph of a arrow like the one in Windows 95.
bgArrowDetect	Show a glyph of either bgArrow, or bgArrow95 depending on the version of windows that you are running.
bgCalendar	Show a glyph of a calendar.
bgDate	Show a glyph of a date
bgUserDefined	Show a glyph from the property ButtonGlyphFileSpec, this can be any standard glyph.


ButtonGlyphFileSpec

Applies to

TAdrockCalendarEdit components

Declaration

property ButtonGlyphFileSpec : String

Description

This property is used only when the property ButtonGlyph is set to bgUserDefined

The filespec must point to a bitmap file *.BMP that can be used as a glyph like those from DELPHI\IMAGES\BUTTONS.

If the file does not exist, then a blank button is displayed.

At the moment to have you know the name of the file for the filespec, you can not search for it with a dialog box, this will be corrected very soon.


Alignment

Applies to

TAdrockCalendarEdit components

Declaration

property Alignment : TAlingment;

Description

This property controls the way a edit control displays the date.

taCenter	Center the date when displaying and editing.
taLeftJustify	Left justify the date when displaying and editing.
taRightJustify	Right justify the date when displaying and editing.


Color Properties

Applies to

TAdrockCalendarEdit components

Declaration

property ColorMonth : TColor;	Color of the month, ie: August 31, 1995, clOlive by default
property ColorSunday : TColor;	Color of Sunday, clRed by default
property ColorMonFri : Tcolor;	Color of the days Monday - Friday, clMaroon by default
property ColorSaturday :  TColor;	Color of Saturday, clRed by default
property ColorNormal : Tcolor;	Color of the days on the month, clBlue by default
property ColorHighlight : Tcolor;	Color of the selected day on the month, ie: August 31, 1995, clPurple by default

Related

property DateBevel : TPanelBevel;	- Either bvNone, bvLowered, or bvRaised which is the default.

Description

The above properties all control how  the calendar will appear when it is shown, all are user definable.


Version

Applies to

TAdrockCalendarEdit components

Declaration

property Version : String;

Description

The version property is read only and contains the version of the edit control.


BadDateMessage

Applies to

TAdrockCalendarEdit components

Declaration

property BadDateMessage : String;

Description

The string contains the message that is displayed when the end user enters an invalid date.


RequiredFieldMessage

Applies to

TAdrockCalendarEdit components

Declaration

property RequiredFieldMessage : String;

Description

The property contains the text that will be displayed when required property is set to true, and the user attempts to leave the edit field without entering a date,


ShowBadAtCalOpen

Applies to

TAdrockCalendarEdit components

Declaration

property ShowBadAtCalOpen : Boolean;

Description

This property determines if the edit control will warn the end user if they have entered an invalid date when they are attempting to open the calendar, either by pressing Alt-Down arrow, or clicking the button with the mouse.


ShowDateOnCalendar

Applies to

TAdrockCalendarEdit components

Declaration

property ShowDateOnCalendar : Boolean;

Description

This property determines if the edit control will display the date on the calendar while the calendar is open.

The date is also displayed on the edit control while the calendar is open so you might not want to have two dates being displayed.


AppendDateFormat

Applies to

TAdrockCalendarEdit components

Declaration

property AppendDateFormat : Boolean;

Description

When the user enters a bad date,  a BadDateMessage is displayed, setting this property to TRUE will append the current Windows short date format to the bad date message string, if FALSE then no date format is appended.

The default bad date message when this property is set to true is as follows:

< BAD DATE > is not a date that can not be recognized!

Please re-enter the date in this format < D/M/YY >

Where < BAD DATE > is the date the user entered, and  < D/M/YY > is the current windows short date format.

This allows you to change the wording for  the bad date message, and still be able to have the short date format appended to your own message.

Set the property BadDateMessage to change the wording for  the message.