mikerabat 20 Posted yesterday at 01:39 PM Following problem: Our main platform for developing our applications is still D2010 (don't ask why..). One of our applications we develop used to use the standard tray icon ballon hints which have a few problems on newer platforms - win 11 especially. So.. the task is to use the toast notification component from D11. To do that I ccreated a small dll that exports a function returning an interface that handles the notification - basically show and cancel the hint. There are some events that may happen in a rapid timing. I carefully designed the dll such that the notifications are only shown and hidden in the main thread. The problem is that I encounter sometimes nasty access violations that I cannot account for... Here is my theory: Showing and hiding toast notifications through the winrt api somehow invokes something like Application.processmessages - I can confirm that during the hide call the show call is reentered (since I put something from a thread in the message queue that triggers a balloon hint to be shown) so either the show call or the hide call result in a nasty AV. (one call on the toastnotification center is not finished and the next one is already there...) I tried to "wait" for the call to be finished but spin waiting blocks the notification stuff too and I actually do not want to have another handler implemented in the d2010 app.... Has anyone experienced something like this (aka is there an easy solution) Could a queue be a solution -> the main app just queues the call an in a message pump (wndproc of an allochwnd call) I handle it myself? Any chance that some winrt init call is missing or can be done different such that it does not show that behaviour? Attached the two files that account for the dll kind regards Mike notifyImpl.pas trayNotifications.dpr Share this post Link to post
mikerabat 20 Posted 3 hours ago I implemented a a timer and posting messages. If we catch a reentrance call I setup a timer that tries again in 50ms - that seems to fix the problem... notifyImpl.pas trayNotifications.dpr Share this post Link to post
timfrost 81 Posted 2 hours ago I don't have an answer to your question, but I have one elderly program which still uses a component called CoolTrayIcon. I still use the version I downloaded in 2006, and it still works faultlessly in Delphi 11 and in Windows 11, though it looks as if I have hardcoded a $define for Delphi_6_UP and changed the BPL/DCP numbers to match the compiler. The same author, Troels Jakobsen, still publishes it on Github. I recall it was easy to work with, and you may just find that using it solves your problem. Share this post Link to post