Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TPlanner
Using TPlannerItem alarms
Using TPlannerItem alarms
Through the Alarm property in a TPlannerItem and alarm handlers, all types of alarms can be triggered by the TPlannerItem. Note that alarms are enabled in the TPlanner by the property TPlanner.EnableAlarms. Different alarm handlers that play sound, send email, show a message, run a script, execute a program can be downloaded from https://www.tmssoftware.com/planaddon.htm
Example:
Following example creates a TPlannerItem in a day mode TPlanner that starts at 2AM and triggers an alarm message 30 minutes before the TPlannerItem starts :
with Planner1.CreateItem do begin ItemStartTime := EncodeTime(2,0,0,0); // 02:00 AM ItemEndTime := EncodeTime(3,0,0,0); // 03:00 AM CaptionText := 'Item 1'; Text.Text := 'This message tells the item starts in 30 minutes'; CaptionType := ctText; Alarm.Active := True; Alarm.Handler := AlarmMessage1; Alarm.TimeBefore := EncodeTime(0,30,0,0); // 30 minutes Alarm.NotifyType := anNotes; end;
Alarm handlers are easy to write. An alarm handler descends for the TPlannerAlarmHandler class which is defined as:
TPlannerAlarmHandler = class(TComponent) public function HandleAlarm(Address,Message:string; Tag, ID: Integer; Item: TPlannerItem): Boolean; virtual; end;
The TAlarmMessage alarm handler defines this function in the following way:
{ TAlarmMessage } function TAlarmMessage.HandleAlarm(Address, Message: string; Tag, ID: Integer; Item: TPlannerItem): Boolean; begin MessageDlg('Alarm for' +Item.CaptionText+#13+ HTMLStrip(Item.Text.Text),mtInformation,[mbok],0); Result := True; end;