TYearPlanner
ReadMe
By
Jonathan Hosking
V1.75 (07/03/2000)
-
Individual
dates can have their own hints and custom colours.
-
Multiple
cells can be selected.
-
Fully customisable
source code, which can be edited if necessary.
-
A popup menu
can be used with the control.
-
Works on
Windows 95 and NT. (I have not tested it with Windows 98)
-
Compact size,
only occupying 34KB when compiled in Delphi 1.0! (28KB in Delphi 5.0!)
The component
code was written by modifying some code for my TOffice97Button component.
The routine that tests for leap years is the routine used in Delphi 5.0. The
code works fine on Delphi 1.0, 2.0, 4.0, 5.0 and C++Builder 3.0, but I have
not tested it with other versions.
You are free
to distribute the code, but you may NOT sell it. If you modify the code, you
must include me in the acknowledgements. If you do want your ideas or modifications
to be incorporated into the latest version, send them to the address at the
end of this document.
Thanks to Simon
Nicholson for helping with the message hook to reduce flickering.
Thanks to Richard
Haven for helping with the heading setup routine.
Thanks to Wolfgang
Kleinrath for helping with the data setup routine and providing
the code for the original routines for loading and saving cell data to INI
files
Thanks to Nacho
Urenda for helping with the size calculation routine.
Thanks to Rob
Schoenaker for helping with the drawing routine.
Thanks to Robert
Gesswein for adding the NoDayPriority and StartDayOfWeek
properties, and for helping with the SetColorAtDate routine.
Thanks to Paul
Fisher for adding printing support, the new routines for loading
and saving cell data to streams, and for helping out with the new cell selection
routines.
Thanks to Paolo
Prandini for removing the range check errors in the component
routines.
Thanks to Max
Evans for the navigation buttons and graphical customisation
improvements.
Thanks to Goldschmidt
Jean-Jacques for the selection information routines.
How
to install the TYearPlanner component
To unzip the
TYearPlanner component, assuming [Program Path] is the path to Delphi
or C++Builder, follow these steps: -
-
Unzip the
file YEARPLAN.ZIP to any directory, using the directory switch (This
is VERY important).
-
Copy the
file YEARPLAN.PAS to the directory [Program Path]\Source\Samples.
-
If you want
documentation, copy the file YEARPLAN.HTM to the directory [Program
Path]\Bin, if you are using Delphi 1.0. Otherwise, copy it to the directory
[Program Path]\Help.
-
If you are
using Delphi 1.0, copy the files in the 16-Bit directory of this
Zip to the directory [Program Path]\Source\Samples. Otherwise, copy
the files in the 32-Bit directory of this Zip to the directory [Program
Path]\Source\Samples.
You can now install
the component into the component library. Follow the procedure for the version
of Delphi or C++Builder that you are using.
Delphi 1.0:
-
Click on
Options and then select Install Components.
-
In the Install
Components dialog, click Add. In the next dialog, click Browse
and open the file YEARPLAN.PAS.
-
Click Ok
to install the component.
Delphi 2.0:
This procedure
should also work with C++Builder 1.0, but I'm not sure.
-
Click on
Component and select Install.
-
In the Install
Components dialog, click Add. In the next dialog, click Browse
and open the file YEARPLAN.PAS.
-
Click Ok
to install the component.
-
Click on
Tools and select Environment Options.
-
In the next
dialog, click on the Library tab and add the full path of the TYearPlanner
source code to the Library Path edit box. Then click Ok.
-
Click on
Component and select Install Component.
-
In the Install
Component dialog, click on the Into existing package tab. Click
on the first Browse button and open the file YEARPLAN.PAS.
Then click on the second Browse button and open the file DCLUSR40.DPK.
Finally, click Ok to install the component.
-
Click on
Tools and select Environment Options.
-
In the next
dialog, click on the Library tab and add the full path of the TYearPlanner
source code to the Library Path edit box. Then click Ok.
-
Click on
Component and select Install Component.
-
In the Install
Component dialog, click on the Into existing package tab. Click
on the first Browse button and open the file YEARPLAN.PAS.
Then click on the second Browse button and open the file DCLUSR50.DPK.
Finally, click Ok to install the component.
C++Builder
3.0:
This procedure
should also work, with minor modifications, with Delphi 3.0 and C++Builder
4.0, but I'm not sure.
-
Click on
Tools and select Environment Options.
-
In the next
dialog, click on the Library tab and add the full path of the TYearPlanner
source code to the Library Path edit box. Then click Ok.
-
Click on
Component and select Install Component.
-
In the Install
Component dialog, click on the Into existing package tab. Click
on the first Browse button and open the file YEARPLAN.PAS.
Then click on the second Browse button and open the file DCLUSR35.BPK.
Finally, click Ok to install the component.
TYearPlanner
Reference
Remarks:
Just in case
you didn't know, here is how you get information about a cell. You get the
day using Day := CurrentDate.Day and the month by using Month :=
CurrentDate.Month. The date details are then obtained with the following:
-
-
For the cell
hint use CellHint := CellData[Month,Day].CellHint.
-
For the cell
color use CellColor := CellData[Month,Day].CellColor.
-
To see if
the date is using a custom color rather than the default use CustomColor
:= CellData[Month,Day].CustomColor.
- To see if a
cell is selected look at CellData[Month,Day].Selected;
To get the start
and end dates in a selection, use the GetStartDate and GetEndDate
routines. Both routines return a TDateTime as the value.
To see if a date
is selected, use the IsCellSelected routine. You need to specify
the date as a TDateTime,
and the return value is a boolean.
You can select
a cell manually using the SelectCell procedure, specifying
a TDateTime as the date to select.
The SetColorAtDate
procedure can be used to set the cell colour
of a date. You need to specify the date, as a TDateTime, the cell colour
and whether or not the control should immediately show the change.
You can use the
LoadFromStream and SaveToStream procedures to load and save
the cell hints to a stream.
Known Problems:
There are currently
no known problems with the control.
Key Properties:
-
property
Align;
Determines
how the control is aligned within its parent.
-
property
Color;
Determines
the colour of the control.
-
property
DayColor;
Determines
the colour of the day cells.
-
property
DayFont;
Determines
the font that is used in the day cells.
-
property
DragCursor;
Determines
the mouse pointer that is displayed when an object is dragged over the control.
-
property
DragMode;
If
this is set to automatic, the control can be dragged and dropped at any
time. If this is set to manual, the control can only be dragged when the
BeginDrag method is called.
-
property
DrawOffScreen;
If
this is set to True, the control is drawn using an off-screen bitmap.
-
property
Enabled;
If
this is set to False, the control cannot be used until this is set
to true.
-
property
EndEllipsis;
If
this is set to True, text is fitted into cells using ellipses.
-
property
FlatCells;
If
this is set to True, cells are drawn in a flat style.
-
property
Font;
Determines
the font that is used in the control.
-
property
GridLines;
If
this is set to True, the gridlines are drawn.
-
property
GridPen;
Determines
the pen that is used for drawing the gridlines.
- property
HeadingColor;
Determines
the colour of the heading cells.
-
property
HintColor;
Determines
the colour of the hints.
-
property
HintDelay;
Determines
the delay time of the hints. A value of 0 uses the application default.
-
property
MonthColor;
Determines
the colour of the month heading cells.
-
property
MonthFont;
Determines
the font that is used in the month cells.
-
property
NoDayColor;
Determines
the colour of the no day cells.
-
property
ParentFont;
If
this is set to True, the control uses the font used by its parent.
-
property
ParentShowHint;
If
this is set to True, the parent of the control displays the hints.
-
property
PopupMenu;
If
this is set, right clicking the control displays the set popup menu.
-
property
Seperator;
If
this is set to True, seperator lines are drawn between the months.
-
property
ShowHint;
If
this is set to True, the control displays its own popup hints.
-
property
SoftBorder;
If
this is set to True, a soft border is drawn around the control.
-
property
UseFreeSpace;
If
this is set to True, the control occupies any unused canvas space.
-
property
Visible;
If
this is set to False, the control cannot be seen.
-
property
WeekendColor;
Determines
the colour of the weekend cells.
-
property
WeekendHeadingColor;
Determines
the colour of the weekend heading cells.
-
property
Year;
Determines
the year to display.
-
property
YearColor;
Determines
the colour of the year cells.
-
property
YearFont;
Determines
the font that is used in the year cell.
-
property
YearNavigators;
If
this is set to True, the year arrows are displayed in the year cell,
allowing the user to navigate forwards or backwards.
-
property
OnClick: TNotifyEvent;
Occurs
when the control is selected.
-
property
OnDblClick: TYearEvent;
Occurs
when the control is double-clicked.
-
property
OnDragDrop: TNotifyEvent;
Occurs
when an object being dragged is dropped.
-
property
OnDragOver: TNotifyEvent;
Occurs
when an object is dragged over the control.
-
property
OnEndDrag: TNotifyEvent;
Occurs
whenever the dragging of an object ends, either by dropping the object or
by cancelling the dragging.
-
property
OnMouseDown: TNotifyEvent;
Occurs
when a mouse button is pressed with the pointer over the control.
-
property
OnMouseMove: TNotifyEvent;
Occurs
when the pointer is moved whilst over the control.
-
property
OnMouseUp: TNotifyEvent;
Occurs
when a mouse button that was pressed is released with the pointer over the
control.
-
property
OnMouseUp: TNotifyEvent;
Occurs
when a mouse button that was pressed is released with the pointer over
the control.
-
property
OnYearChange: TYearEvent;
Occurs
when the year changes.
-
CellData;
This
contains the information about the dates. Set CellHint to give the
date a hint. Set CellColor to set the cell colour, and set CustomColor
to use the specified colour. The array is reset when the year changes, and
changes do not automatically update the control. The Selected
variable indicates if a cell has been selected.
-
CurrentDate;
This
contains the current date. Day is the day and Month is the
month, quite simply.
Revision
History
- Added
a new SelectCell procedure which allows the user
to manually select a cell.
V1.74
(22/02/2000)
- Added
a new OnYearChange event procedure which occurs
when the year changes.
V1.73
(19/02/2000)
- Bug
Fixed - When multiple TYearPlanners were used on a form, they were
sharing the same hint windows and some other internal variables.
V1.72 (12/02/2000)
V1.71 (06/02/2000)
- Bug Fixed
- The mouse procedures now respond properly. In previous versions, the
mouse procedures weren't called sometimes.
V1.7 (25/01/2000)
- Bug Fixed
- The control now uses the correct colour to draw gridlines.
- Added DayFont,
MonthFont and YearFont properties which
allow the user to control the font used in day cells, month cells and
the year cell. Thanks to Max
Evans for providing the code.
- Added an
EndEllipsis property, allowing the text to fit into cells
using ellipses. Thanks to Max
Evans for providing the code.
- Added a
FlatCells property which allows the cells to be flat.
Thanks to Max
Evans for providing the code.
- Added a
GridPen property, allowing the user to change the pen
used for the gridlines. As a result, the
GridLineColor property has been removed. Thanks to Max
Evans for providing the code.
- Added a
GridLines property which toggles the display of gridlines.
Thanks to Max
Evans for providing the code.
- Added a
Separator property, allowing a simple separator between
the months. Thanks to Max
Evans for providing the code.
- Added a
SoftBorder property, which allows the control to have
a soft style border. Thanks to Max
Evans for providing the code.
- Added a
YearColor property, allowing the user to change the colour
of the year cell. Thanks to Max
Evans for providing the code.
- Added a
YearNavigators property which toggles the display of
the year arrows in the year cell to allow navigation forward or backward.
Thanks to Max
Evans for providing the code.
V1.63 (22/01/2000)
- Bug Fixed
- Fixed the irritating problem with the tagSize data type
in 32-Bit compilation. A tSize data type is now used instead,
and this seems to work perfectly.
- The OnDblClick
procedure now returns the coordinates of a selected range of cells.
-
Bug Fixed
- Some of the routines caused errors if range checking was enabled. Thanks
to Paolo Prandini
for correcting the routines.
- Bug Fixed -
The component was using a tagSize data type for 32-Bit compilation.
It seems that Delphi 2.0 and C++Builder 1.0 do not have this data type.
-
Bug Fixed
– In V1.6, I accidentally disabled the OnClick event procedure.
-
The user
can now choose whether to use a TStream or TBlobStream for loading and saving
cell data.
-
Added a
NoDayPriority property, allowing the user to select whether blank
cells are have the same colour. Thanks to Robert
Gesswein for providing this.
-
Added a
StartDayOfWeek property, allowing the user to select the day that
appears at the left of the component. Thanks to Robert
Gesswein for providing this.
-
Added a
SetColorAtDate routine, allowing the user to select a cell colour
for a date. Thanks to Robert
Gesswein for helping with this.
-
The component
is now much faster at painting itself. Thanks to Rob
Schoenaker for helping with the drawing routine.
-
Added a DrawOffScreen
property, allowing the control to be drawn using an off-screen bitmap.
-
Added a HintColor
property, allowing the user to change the colour of hints.
-
Added a MonthColor
property, allowing the user to change the colour of the month headings.
-
Added a
new UseFreeSpace property, allowing the control to make use of any
unused canvas space. Thanks to Nacho
Urenda for helping with the size calculation routine.
-
Added comments
to the routines for loading and saving the cell data. Thanks to Wolfgang
Kleinrath for providing the comments.
-
You can
now load and save the cell data to files. Thanks to Wolfgang
Kleinrath for providing the code for the routines. A
new IniFileName property has been added so you can set the filename.
-
New HintDelay
property added, allowing you to adjust the hint delay.
-
The hint
string restriction has been removed, except in Delphi 1.0.
-
Bug Fixed
– The top left cell now updates when the year changes.
-
The cX
and cY variables are no longer public, as I have added a new CurrentDate
property which stores the current date.
-
Multiple
line cell hints are supported! Just add return characters to the hint string
where needed.
-
Delphi 5.0
is now supported!
-
Added a
message hook to help reduce flickering. Thanks to Simon
Nicholson for his help with this.
Future
Ideas
I currently only
have no ideas for future versions of the TYearPlanner component.
Other
Components
Below is a list
other components that I have written: -
-
TLCD99 –
A control that looks like an LCD display.
-
TOffice97Balloon
– A control that looks and acts like the Office Assistant balloons in Office
97.
-
TOffice97Button
– A control that looks and acts like the controls (Buttons, radiobuttons,
up buttons and down buttons) that appear in the Office Assistant balloons
in Office 97.