unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, System.Notification;
type
TForm1 =
class(TForm)
btnSendNotification: TButton;
procedure FormCreate(Sender: TObject);
procedure btnSendNotificationClick(Sender: TObject);
private
{ Private-Deklarationen }
ANotificationCenter: TNotificationCenter;
procedure RecieveLocalNotification(Sender: TObject; ANotification: TNotification);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnSendNotificationClick(Sender: TObject);
begin
var tmpNotification: TNotification;
tmpNotification := TNotification.Create;
tmpNotification.
Name := '
Windows Notification';
tmpNotification.Title := '
My first Notification';
tmpNotification.AlertBody := '
Notification send by my application.';
ANotificationCenter.PresentNotification(tmpNotification);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ANotificationCenter := TNotificationCenter.Create(Self);
ANotificationCenter.OnReceiveLocalNotification := RecieveLocalNotification;
end;
procedure TForm1.RecieveLocalNotification(Sender: TObject; ANotification: TNotification);
begin
Beep;
end;
end.