Calendar Works home page

Overview

Components
TcwDayView
TcwWeekView
TcwMonthView
TcwManager
TcwEvents
TcwMemoryEvents

Classes
TcwEvent
TcwEventIterator

Additional Information
Constants & Types
Miscellaneous routines
HTML Reference
FAQ's Frequently asked questions
Tips & Tricks

Help File
Download help file

Feedback
Report a bug with this manual

How do you rate this manual?
Great
OK
Poor

Comments


Best viewed with
Microsoft Internet Explorer
Calendar Works Tips & Tricks

1. Easy formatting with HTML
2. Creating hotspots in a cell
3. Focus / Selection styles
4. Customization
5. Locking cells
6. Iterating through selected cells
7. Finding a date or time

Watch this space, more tips are coming soon, including drag & drop techniques.

Have a tip you wish to share with others? Please email your tip to tips@innovasoftware.com and we will add it to this page along with due credit to yourself as author.


1. Easy formatting with HTML

Easy formatting with HTML The HTML capabilities of Calendar Works make it easy to format the contents of a cell.

For more information on the supported HTML commands see the HTML Reference


Example Formatting a cell using HTML.
The example below assumes there is a TImage on the form named BellBitmap


var
   Cell : TcwDayViewCell;
begin
   Cell := cwDayView1.GetCell(EncodeDate(1998, 11, 20),
                              EncodeTime(9,0,0,0));
   if Cell <> nil then
      Cell.Text :=
         '<IMG IMAGE=BellBitmap> ' +
         'Call <B>Matthew</B> on ' +
         '<A 0299557778>(02) 9955-7778</A> ' +
         '<B><FONT COLOR="#FF0000">Urgent</FONT></B>';
end;


2. Creating hotspots in a cell

Multiple clickable hotspots (or anchors) can be easily created in each cell by using the HTML anchor command.

These hotspots will generate the OnAnchorClicked event when clicked.

For more information see the HTML Reference



3. Focus / Selection styles

Focus and selection styles Shown below are the differences between ssOutline and ssSolid styles of the FocusStyle and SelectionStyle properties.

In these examples the MultiSelection property was set to true and multiple cells have been selected.



4. Customization

Using OnInitialize The easiest way to customize the appearance of your MonthView, WeekView or DayView component is by using the OnInitialize event.

Example Using OnInitialize to customize appearance.
The example below assumes there is a TImage on the form named HolidayBitmap



procedure TForm1.cwMonthView1OnInitialize(Sender : TObject);
var
   Cell : TcwMonthViewCell;
begin
   Cell := cwMonthView1.GetCell(EncodeDate(1999, 1, 1));
   if Cell <> nil then
      Cell.Text := Cell.Text + ' <BR>' +
                   '<IMG IMAGE=HolidayBitmap> ' +
                   'New years day';
end;


5. Locking cells

You can prevent the user from selecting a given cell by locking it.

Locking a cell does not change it's appearance. You might want to make your locked cells appear disabled by setting their color to clGray


Example Lock Jan 1st 1999 and also set color to clGray

var
   Cell : TcwMonthViewCell;
begin
   Cell := cwMonthView1.GetCell(EncodeDate(1999, 1, 1));
   if Cell <> nil then begin
      Cell.Locked := true;
      Cell.Color := clGray;
   end;
end;


6. Iterating through selected cells

Use the RowCount, ColumnCount and Cell properties to iterate through the cells displayed on a MonthView, WeekView or DayView component

Example Set the color of every selected cell to clRed

var
   Cell : TcwMonthViewCell;
   r, c : integer;
begin
   for r := 0 to cwMonthView1.RowCount - 1 do
      for c := 0 to cwMonthView1.ColumnCount - 1 do begin
         Cell := (cwMonthView1.Cell[c, r]
                  as TcwMonthViewCell);
         if Cell.Selected then
            Cell.Color := clRed;
      end;
end;


7. Finding a date or time

Use the GetCell function to return the cell that represents the given date/time.

This function returns nil if there is no cell that represents the given date/time.


Example Find the cell that represents Jan 1st 1999

var
   Cell : TcwMonthViewCell;
begin
   Cell := cwMonthView1.GetCell(EncodeDate(1999, 1, 1));
   if Cell <> nil then (* Check for nil *)
      (* Do something with the cell here *)
end;

Example Find the cell that represents 9:30am on 20th November 1998

var
   Cell : TcwDayViewCell;
begin
   Cell := cwDayView1.GetCell(EncodeDate(1998, 11, 20) +
                              EncodeTime(9, 30, 0, 0));
   if Cell <> nil then (* Check for nil *)
      (* Do something with the cell here *)
end;



Copyright © 1998-2007 Innova Software ALL RIGHTS RESERVED
All trademarks are the property of their respective owners.
Webmaster webmaster@innovasoftware.com