Recent

Author Topic: Toast notifications on Windows 10  (Read 4214 times)

slicke

  • New Member
  • *
  • Posts: 12
Toast notifications on Windows 10
« on: September 22, 2019, 05:56:30 pm »
Hi!

Has anyone managed to port Windows 10 desktop notifications/toasts (like the example on https://code.msdn.microsoft.com/windowsdesktop/Sending-toast-notifications-71e230a2/sourcecode?fileId=51046&pathId=1859297009) to Lazarus/FPC?

I've tried porting the code above, but my C++ isn't good enough. Is there any available library for this?

Thanks!

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
« Last Edit: September 23, 2019, 07:46:38 am by Thaddy »
Specialize a type, not a var.

CCRDude

  • Hero Member
  • *****
  • Posts: 596
Re: Toast notifications on Windows 10
« Reply #2 on: November 11, 2019, 05:37:46 pm »
I started looking into the same thing today.

Marco Cantus blog has two links. One Dropbox link that's no longer available, and the "enhanced" version by AdSoft via Mega. The Embarcadero link basically points to Marco Cantus blog as well, mentioning that the code could be backported to Delphi XE 2.

Issue #1: many files in that later archive are Delphi RTL files, not clean translations to be reused freely.
Issue #2: unit names are using namespaces, which is easy to fix.
Issue #3: some units are unavailable in Lazarus. Looks like we can do without them. pngimage can be replaced with lazpng from package imagesforlazarus.
Issue #4: Imports are "delayed", which is not yet supported by FPC. Would need to be rewritten to dynamical dynamical loading if the code can be made to work in the first place.

You can make the code compile within an hour (setting a few $MODE Delphi, removing some unrequired code and adding some imports). It's not working right out of the box; i might spend another hour or two trying to get it to work.

@slicke: have you started (or even finished) getting the Delphi code to run on Lazarus?

CCRDude

  • Hero Member
  • *****
  • Posts: 596
Re: Toast notifications on Windows 10
« Reply #3 on: November 12, 2019, 08:36:26 am »
I have it running now, but it needs a lot of cleanup to make it (re-)usable. Will try to wrap it in a separate unit and see if I can define imports etc. without reusing Delphi RTL files.

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
Re: Toast notifications on Windows 10
« Reply #4 on: November 12, 2019, 08:48:00 am »
I also got it working , but I always use {$mode delphi} by default when handling Delphi units. Waste of time to use {$mode objfpc}
Specialize a type, not a var.

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: Toast notifications on Windows 10
« Reply #5 on: June 11, 2020, 04:38:46 pm »

I realize this is an old(er) topic, but I was wondering if any of you (Thaddy/CCRDude) have some example code (cleaned up or not)?


I did follow the suggested links, however;
- The MSDN example seems to jump to a generic page,
- The VLC WinRT blog post no longer has the (dropbox) download available, and
- The Embarcadero forum shows an error message (java.lang.NullPointerException).


Any input/suggestions/code would be appreciated.

 

TinyPortal © 2005-2018