- You are here:
- Home
- CodeXchange
- All
- PowerBuilder
- Toast Notification's Utility
Toast Notification's Utility
- Ramón San Félix Ramón
- Code Author
- Offline
Less
More
- Posts: 30
1 year 1 month ago #487
by Ramón San Félix Ramón
This message has an attachment file.
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.
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.
- Sivaprakash BKR
- Offline
Less
More
- Posts: 2
1 year 6 days ago #502
by Sivaprakash BKR
Sivaprakash BKR replied the code: Toast Notification's Utility
Hello,
Thanks for the nice utility. I did incorporate that into my application. It's working fine under most circumstances. And I did face one issue on this condition.
1. I have two windows, a. Login window b. Profile creation window
2. From login window, I open the profile creation window, which is a response window.
3. I add one entry and use the notification utility to inform as such. The toast waits for 5 seconds and then goes off.
4. If I wait for that 5 seconds, then close that profile creation window, no issues.
5. If I don't wait for 5 seconds, immediately close the profile creation window, the control is back to login window. When the control is in login window, keeping it idle makes the application to close.
6. This issue is not there, when I wait for that 5 seconds, then close [ Toast Notification will go off ], the profile window.
Any workaround to solve this issue.
Thanks for the nice utility. I did incorporate that into my application. It's working fine under most circumstances. And I did face one issue on this condition.
1. I have two windows, a. Login window b. Profile creation window
2. From login window, I open the profile creation window, which is a response window.
3. I add one entry and use the notification utility to inform as such. The toast waits for 5 seconds and then goes off.
4. If I wait for that 5 seconds, then close that profile creation window, no issues.
5. If I don't wait for 5 seconds, immediately close the profile creation window, the control is back to login window. When the control is in login window, keeping it idle makes the application to close.
6. This issue is not there, when I wait for that 5 seconds, then close [ Toast Notification will go off ], the profile window.
Any workaround to solve this issue.
Please Log in or Create an account to join the conversation.
Moderators: Appeon Administrator