Jump to content
mikerabat

tray notification dll delphi11.3/Delphi 2010

Recommended Posts

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

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

Thanks for the suggestion. I'll try that one though I think it will not solve our problem in the first place - we already use the TTrayIcon component that allows to show balloon hints in the tray.

BUT... (there is always a but..) we have a hard time to cancel the hints if they occure in a rapid way. That was no problem in winxp and win7 - there it worked well - but on newer

OS's the tray does not cancel properly but rather shows the hint for a few seconds. This is quite annyoing for users since all the action has already been done and the hints still pop up.

Note that we do not know in beforehand how long the hints are shown - sometimes it takes long (depeding on the amount of data transferred) sometimes it is fast...

 

The newer toast notifications seem to resolve that problem but have this other nasty problem ... Anyhow I think the last change did the trick...

Share this post


Link to post
1 hour ago, mikerabat said:

Note that we do not know in beforehand how long the hints are shown - sometimes it takes long (depeding on the amount of data transferred) sometimes it is fast... 

 

 

Then why don't you delegate the hint showing to a task running in a secondary thread? The task can wait for a short interval and if it is cancelled before that interval has elepsed the hint will not be shown at all...

Share this post


Link to post
22 hours ago, PeterBelow said:

Then why don't you delegate the hint showing to a task running in a secondary thread? The task can wait for a short interval and if it is cancelled before that interval has elepsed the hint will not be shown at all... 

As I see that this is the same mechanism just not in the main thread.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×