Toast Notification's Utility

Ramón San Félix Ramón
CODE AUTHOR
Posts: 28
 10 months 4 weeks 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.

Marcelo Gil
 7 months 2 weeks ago #511 by Marcelo Gil
Marcelo Gil replied the code: Toast Notification's Utility
Genial! muchas gracias

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

Ramón San Félix Ramón
CODE AUTHOR
Posts: 28
 7 months 2 weeks ago #510 by Ramón San Félix Ramón
Ramón San Félix Ramón replied the code: Toast Notification's Utility
Hola Marcelo,

Esta utilidad no usa ninguna librería .Net, usa declaración de funciones externas para manejar funciones de Windows.

Saludos.

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

Marcelo Gil
 7 months 3 weeks ago #509 by Marcelo Gil
Marcelo Gil replied the code: Toast Notification's Utility
Hola Ramon! como estas ?
Esta funcionalidad aplica para PB 2022 R2 ?
Entiendo que a partir de esta version de PB no se pueden utilizar DLL generadas en .net framework. (pasan a .net core)

Muchas gcs
Sldos

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