Grey Calendar
 TGreyCal Component

Properties	Event's	  	Run Demonstration

Description

The TGreyCal component is a variation of the calendar control supplied as a sample with Delphi. When you create a TGreyCal it is initially set to todays date and appears as a 3D fixed size calendar.

TGreyCal is fully configurable apart from its size which remains fixed as does the size of the font. However the actual font used is configurable. This is the only restriction that this version has

Use

Once the calendar has been incorporated into a program and run, clicking on the dates will change the displayed date and the value of CalendarDate which can be used to supply a date for another use by adding code to the OnChange event.

Clicking on the chevrons will either advance or  reduce the selected month by one. If the selected date exceeds the number of days in the newly selected month the day will revert to the last day of the month. Except in February in a leap year because I couldnt be bothered.


Properties

Cursor	Height	Name	Tag

Day 	HelpContext    	SatColour	 Top

DisplayColour	Hint	Showhint	Visible

Enabled	Left	StartOfWeek	Width

FontName	Month	SunColour	Year


Day
Day Integer default today

See also

The Day property is available at both design and at runtime, and allows the setting of the Day of month by use of an integer value. Note There is no built in error checking to ensure that the user entered a valid Day, an invalid integer value is ignored and Delphi handles it if a string value is entered.

 Example.

The Day in the Calendar Control in this example changes each time the user enters a valid Day of the month in the edit box and presses the return key.

procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;  Shift: TShiftState);

begin

      {only change if user enters return key}

      if Key = 13 then GreyCal1.Day := StrToInt(Edit1.text);

end;


DisplayColour
DisplayColour  TColor default clBlue

See also

The DisplayColour property is available at both design and at runtime, and allows the colour used to display the selected date to be customized.

Example

This example uses the supplied TColorDialog to set the displayed colour in the calendar.

procedure TForm1.Button4Click(Sender: TObject);

begin

     {ensures TColorDialog starts with current colour}

     ColorDialog1.Color := GreyCal1.DisplayColour ;

     ColorDialog1.execute;    {Fires up the dialog}

     {On return sets Calendar Display to chosen colour}

     GreyCal1.DisplayColour  := ColorDialog1.Color;

end;


FontName
FontName String default MS Sans Serif

See also

The FontName property is available at both design and at runtime, and allows the font used in the calendar to be customized. In design mode the normal Font drop down list is used to select the required font.

Example

This example changes the Font used in the calendar to Times New Roman.

procedure TForm1.FontButtonClick(Sender: TObject);

var

   m_FontName :  String;

begin

      {puts the font in the variable}

      m_FontName := 'Times New Roman' ;

     {changes the calendar Font }

     GreyCal1.FontName := m_FontName;

end;


Month
Month  Integer default today

See also

The Month property is available at both design and at runtime, and allows the setting of the Month of the Year by use of an integer value. Note There is no built in error checking to ensure that the user entered a valid Month, an invalid integer value is ignored and Delphi handles it if a string value is entered.

 Example.

The Month in the Calendar Control in this example changes each time the user enters a valid Month of the Year in the edit box and presses the return key.

procedure TForm1.Edit2KeyUp(Sender: TObject; var Key: Word;  Shift: TShiftState);

begin

      {only change if user enters return key}

      if Key = 13 then GreyCal1.Month := StrToInt(Edit2.text);

end;


SatColour
SatColour  TColor default clBlue

See also

The SatColour property is available at both design and at runtime, and allows the colour used to display Saturday's to be customized.

Example

This example uses the supplied TColorDialog to set the displayed colour for Saturday's during the month displayed in the calendar.

procedure TForm1.Button2Click(Sender: TObject);

begin

     {ensures TColorDialog starts with current colour}

     ColorDialog1.Color := GreyCal1.SatColour;

     ColorDialog1.execute;    {Fires up the dialog}

     {On return sets Calendar Saturday's to chosen colour}

     GreyCal1.SatColour := ColorDialog1.Color;

end;


StartOfWeek
StartOfWeek  Integer default 0 {Monday}

See also

The StartOfWeek property is available at both design and at runtime, and allows the first day shown on the calendar to be customized by changing the integer value. With Monday = 0 through to Sunday = 6.

Example

This example changes the start of the week to Sunday.

procedure TForm1.RadioButton7Click(Sender: TObject);

begin

    {changes first day displayed to Sunday}

   GreyCal1.StartOfWeek := 6;

end;


SunColour
SunColour  TClolor default clRed

See also

The SunColour property is available at both design and at runtime, and allows the colour used to display Sunday's to be customized.

Example

This example uses the supplied TColorDialog to set the displayed colour for Sunday's during the month displayed in the calendar.

procedure TForm1.Button3Click(Sender: TObject);

begin

     {ensures TColorDialog starts with current colour}

     ColorDialog1.Color := GreyCal1.SunColour;

     ColorDialog1.execute;    {Fires up the dialog}

     {On return sets Calendar Sunday's to chosen colour}

     GreyCal1.SunColour := ColorDialog1.Color;

end;


Year
Year Integer default today

See also

The Year property is available at both design and at runtime, and allows the setting of the  Year by use of an integer value. Note There is no built in error checking to ensure that the user entered a valid Year, an invalid integer value is ignored and Delphi handles it if a string value is entered.

 Example.

The Year in the Calendar Control in this example changes each time the user enters a valid  Year in the edit box and presses the return key.

procedure TForm1.Edit3KeyUp(Sender: TObject; var Key: Word;  Shift: TShiftState);

begin

      {only change if user enters return key}

      if Key = 13 then GreyCal1.Year := StrToInt(Edit3.text);

end;


Event's
Events

OnChange

OnClick

OnDblClick


OnChange

Declaration

property OnChange: TNotifyEvent;

The OnChange event occurs when the value of CalendarDate  in the TGreyCal component is modified. For example, OnChange occurs when the Day property of TGreyCal is modified, or when the user clicks on the Calendar with either a left or right button.

Example.

The date in the Label Control in this example changes each time the user clicks on a date in the Calendar:

procedure TForm1.GreyCal1Change(Sender: TObject);

begin

    Label1.caption := FormatDateTime( 'dd mmm yy',

                                      GreyCal1.CalendarDate);

end;


TGreyCal

Thank you for your interest in TGreyCal. Version 1.1 was written by Graham Winter and can be registered by sending a cheque for £5.00 to:

Mr. G M Winter

44 Southfield Road

Pocklington

York YO4 2XE.

I can be contacted on CompuServe ID 100025,1056 if you have any problems, questions or anything else.


Change_Day
Clicking here changes the day.


Advance_Month
Clicking here goes to the next month..


Back_Month
Clicking here goes to the previous month.