BSOne.SFC/Tocsg.Lib/VCL/Tocsg.Notification.pas

53 lines
1.5 KiB
Plaintext

{*******************************************************}
{ }
{ Tocsg.Notification }
{ }
{ Copyright (C) 2022 kku }
{ }
{*******************************************************}
unit Tocsg.Notification;
interface
uses
System.SysUtils, Winapi.Windows;
procedure ShowNotification(sTitle, sText: String);
implementation
uses
System.Notification, Vcl.Forms;
procedure ShowNotification(sTitle, sText: String);
var
NotificationCenter: TNotificationCenter;
Notification: TNotification;
// Channel: TChannel;
begin
NotificationCenter := TNotificationCenter.Create(nil);
Notification := NotificationCenter.CreateNotification;
if Notification <> nil then
begin
// Channel := NotificationCenter.CreateChannel;
try
Notification.Name := Format('Notification-%d', [GetTickCount]);
Notification.Title := sTitle;
Notification.AlertBody := sText;
NotificationCenter.PresentNotification(Notification);
// Channel.Id := Format('Channel-%d', [GetTickCount]);
// Channel.Title := sTitle;
// Channel.Importance := TImportance.High;
// NotificationCenter.CreateOrUpdateChannel(Channel);
finally
Notification.Free;
// Channel.Free;
NotificationCenter.Free;
end;
end;
end;
end.