AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Windows Notification Reaktion

Ein Thema von sjansen · begonnen am 3. Feb 2022 · letzter Beitrag vom 4. Feb 2022
Antwort Antwort
sjansen

Registriert seit: 16. Okt 2019
Ort: Siegen
9 Beiträge
 
Delphi 10.4 Sydney
 
#1

Windows Notification Reaktion

  Alt 3. Feb 2022, 09:07
Delphi-Version: 10.4 Sydney
Hi,

ich habe eine Verständnis Frage bzgl (Windows)-Notifications.

Einfacher ist vermutlich wenn ich erkläre, was ich erreichen möchte.
Wenn ein Benutzer auf eine gesendete Notification klickt, möchte ich eine Action ausführen (einen Link öffnen oder ein ShellExecute).
In RecieveLocalNotification komme ich aber nur, wenn die Notification noch gezeigt wird. Befindet sich die Notification nicht mehr auf dem Bildschirm, sondern wird nur noch im Benachrichtigungs-Teil von Windows angezeigt, funktioniert das ganze nicht mehr. Lässt sich das überhaupt umsetzen?

Vielen Dank

Delphi-Quellcode:
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.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.110 Beiträge
 
Delphi 12 Athens
 
#2

AW: Windows Notification Reaktion

  Alt 3. Feb 2022, 16:19
Nein, du machst alles richtig ... von dort kommt das Event einfach nie.

Es hilft auch kein tmpNotification.HasAction := True; .
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Benutzerbild von Union
Union

Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.487 Beiträge
 
Delphi 7 Enterprise
 
#3

AW: Windows Notification Reaktion

  Alt 3. Feb 2022, 20:37
Wenn man das liest, wundert man sich nicht über die unvollständige Implementierung. Denn da die Aktivierung aus dem Action Center auch erfolgen kann, wenn das Programm gar nicht läuft, muss man ein COM erstellen und registrieren, das dafür sorgt dass die App auch bereit zur Verarbeitung ist. Viel Spass, die Grundlagen dafür sind in Winapi.UI.Notifications vorhanden.
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all
  Mit Zitat antworten Zitat
sjansen

Registriert seit: 16. Okt 2019
Ort: Siegen
9 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Windows Notification Reaktion

  Alt 4. Feb 2022, 08:57
Schonmal gut zu wissen, dass es eine fehlender Implementierung ist und ich nicht einfach zu blöd bin

Hab zwei Beiträge in die Richtung gefunden:

https://stackoverflow.com/questions/...h-toastgeneric
https://blog.marcocantu.com/blog/201...vcl-winrt.html
Ggf. noch http://blog.blong.com/2020/09/delphi-and-winrt-api.html

Da eine saubere Implementierung aber vmtl etwas mehr Aufwand ist, werd ich das ganze wohl erstmal ruhen lassen und zu gegebener Zeit darauf zurück kommen.
  Mit Zitat antworten Zitat
Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.685 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Windows Notification Reaktion

  Alt 4. Feb 2022, 10:42
Von Marco Canto gibt es auf seinem GitHub eine voll funktionierende Demonstration.
Leider auch da ohne das was der TE sich wünscht.
Gruß vom KodeZwerg
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz