Einzelnen Beitrag anzeigen

Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: Win 10 Notification wird als Balloon angezeigt, aber nicht im Notification Center

  Alt 16. Jul 2018, 17:16
Habe gerade mal nachgeschaut:

Ich mache das so für eine Anwendung und funktioniert

Delphi-Quellcode:
procedure TAppForm.checkToastActionCenterKey(const StayInCenter: Integer);

const
   cKeyname = 'Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\';
   cActionKey = 'ShowInActionCenter';
var
   Reg: TRegistry;
   OpenResult: Boolean;
   lKey: string;
begin
   lKey := cKeyname + getRegisterToastMessage + '\';
   Reg := TRegistry.Create(KEY_WRITE);
   try
      Reg.RootKey := HKEY_CURRENT_USER;
      OpenResult := Reg.OpenKey(lKey, true);

      if not OpenResult then
         Exit();

    { Checking if the values exist and inserting when neccesary }

      if not Reg.KeyExists(cActionKey) then
         Reg.WriteInteger(cActionKey, StayInCenter); // else

      Reg.CloseKey();
   finally
      Reg.Free;
   end;

end;

function TAppForm.getRegisterToastMessage: string;
const
   AppId = 'Embarcadero.DesktopToasts.';
begin
   result := AppId + THashBobJenkinsGetHashString(ParamStr(0));
end;

procedure TAppForm.SendToastMessage(const Value: string);
var
   MyNotification: TNotification;
begin
   MyNotification := fNotification.CreateNotification;
   try
      MyNotification.Name := 'Fritz';
      MyNotification.Title := 'MyTost';
      MyNotification.AlertBody := Value;
      MyNotification.AlertAction := '';;
      MyNotification.HasAction := true;

      fNotification.PresentNotification(MyNotification);
   finally
      MyNotification.Free;
   end;
end;

procedure TAppForm.FormCreate(Sender: TObject);
begin
   fNotification := TNotificationCenter.Create(self);
   checkToastActionCenterKey(1);
end;
Habe aber System.Notifactions als Source im Projekt
Fritz Westermann

Geändert von Fritzew (16. Jul 2018 um 17:23 Uhr)
  Mit Zitat antworten Zitat