delphijedi

JEDI Visual Component Library : JvAlarms component (a few questions)


I decided to try the JvAlarms component. So I did :

procedure TForm1.Button1Click(Sender_TObject);
begin
jvAlarms1.Add.Name :=Edit1.Text;
jvAlarms1.Add.Time := dxDateTimeWheelPicker1.DateTime;
label1.caption:=datetimetostr(dxDateTimeWheelPicker1.DateTime);
jvAlarms1.Active:=True;
end;

Now, the strange part is that when I set the alarm and run the application,immediately I get a popup window with my alarm message. Is this by design ? After I close this message the application will later trigger the alarm I have set on time.I am just wondering if this immediate popup window is by default or you can turn it off and how. If you can not, is it possible to modify it so you can at least say something to the user like 'you have set the alarm : alarm name, to fire : alarmtime'.

Second question regards the alarm message. How do you get the alarm message name when the alarm fires ?

I tried :

ShowMessage('Alarm:'+ jvAlarms1.Name);

but it does not seem to work. I can get it with :

ShowMessage('Alarm:'+jvAlarms1.Items[0].Name;

But I do not know the indexes of the alarms added!? So I can not use that. Any way I can retrieve the list of alarms added by my code ?

Third question regard the alarms storage. Do you load them from *.ini or can you use a database ? I could not find examples of such usage anywhere (over here search results turn '0') so I would be grateful if someone could point me in the right direction.


Solution

  • You added two alarms because you called Add twice. Call it once instead:

    var
      Item: TJvAlarmItem;
    .... 
    Item := jvAlarms1.Add;
    Item.Name :=Edit1.Text;
    Item.Time := dxDateTimeWheelPicker1.DateTime;
    

    When the alarm fires the component's OnAlarm event receives a reference to the specific alarm that fired. You can read the name from that reference.

    It is entirely up to you where you store the alarms in your application.