Toast Notification's Utility

Ramón San Félix Ramón
CODE AUTHOR
Posts: 31
 1 year 2 months ago #487 by Ramón San Félix Ramón
Ramón San Félix Ramón created the code: Toast Notification's Utility
I want to share with the appeon community an example that I published on my blog in March 2023.

These are toast notifications, which I think add a touch of modernity to our PowerBuilder applications.

The first thing I have to thank is Chris Pollach who has published an example with his Framework on which I have based it.
Here is the link to the Windows Notification Utility project:

sourceforge.net/projects/stdfndclass/files/Applications/PowerBuilder/Notification

Well, the first thing I did was separate the nc_systemtray_master class from its framework.

To do this I have created a non-visual object called n_cst_systemtray in which I have copied all the logic from nc_systemtray_master. It was quite simple, I just had to create the ib_rc variable that is in the ancestor of nc_systemtray_master (nc_master) and I eliminated the oe_documentation event. With this I have now been able to use only the class without anything else from the framework.

For my example I have added a variable called ib_HideWindow, since I do not want the window that calls the notification to become invisible, so I have modified the of_add_to_systemtray() functions by adding the IF condition ib_HideWindow THEN ao_window.Hide().

I had to create a function called of_get_systemtray_active() to know when we have sent the window to the SystemTray, it simply returns the private variable ib_systemtray_active, I could have put this public variable but I have chosen to respect the original class as much as possible.

As a last modification to the class I have added that the state is saved in the private variable ib_systemtray_active within the of_delete_from_systemtray() function. This way I will know when the Systemtray notification has been removed.

Once I had the class prepared, I had several headaches to make the notifications independent of the application and eliminate themselves after a few seconds.

After several tests, I remembered an example of programming in MultiThread or MultiThead and I tried to apply those concepts in this example.

To do this I had to create the n_cst_systemtray_shared class and the n_cst_systemtray_callback class to help me achieve it.

In summary, you have to create an object that is executed in another thread, in this case the n_cst_systemtray_shared object. This is responsible for waiting a few seconds before calling the other n_cst_systemtray_callback object that will eliminate the notification.

The summary explanation of why two objects must be used is because the shared object used for Multithreading cannot invoke any object that is visual, that must be done by the second object...

Since I don't want to make this article much longer, I leave you a link to an interesting article that talks about the topic:

Community.appeon.com/.../339-free-my-gui-multi-threading-in-powerbuilder

Anyway, I leave the link to the project on GitHub and on my blog, where I have extended the explanation a little more in Spanish.

github.com/rasanfe/toast

rsrsystem.blogspot.com/2023/03/toast-notifications-utility.html

Additionally, I upload the zipped project as an attachment here.

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

Ramón San Félix Ramón
CODE AUTHOR
Posts: 31
 1 week 8 hours ago #580 by Ramón San Félix Ramón
Ramón San Félix Ramón replied the code: Toast Notification's Utility
Well, I don't know what can happen, I just tested the 32-bit app from the IDE and it worked. Screenshot attached.

Attachments:

Please Log in or Create an account to join the conversation.

Vassilis Filippopoulos
Posts: 3
 1 week 12 hours ago #579 by Vassilis Filippopoulos
Vassilis Filippopoulos replied the code: Toast Notification's Utility
Hi Ramon and thank you for your reply.
We use 32bit. What should I change in order to work for a 32bit ?
As I mentioned, the executable works fine, but from PB IDE it does not work.

Please Log in or Create an account to join the conversation.

Ramón San Félix Ramón
CODE AUTHOR
Posts: 31
 1 week 1 day ago #578 by Ramón San Félix Ramón
Ramón San Félix Ramón replied the code: Toast Notification's Utility
When you compile, do you compile to 32 or 64 bits? I don't remember if I set the example to 64 bits, I imagine so, but it doesn't matter, make sure that when you run it in the IDE you are in 32 or 64 bits according to what works for you in compilation.

Please Log in or Create an account to join the conversation.