1. Jeferson Neves
  2. PowerBuilder
  3. Thursday, 24 February 2022 12:26 PM UTC

Hi,
I would like some help to solve a problem. I have an application that runs in the background, displaying only an icon in the system tray. However, this icon does not disappear when closing the application, and when opening it again, another icon appears, accumulating several, but all icons will disappear when you mouse hover. I wanted to know how to update, via code, so I don't have to hover over them to disappear.
I use Powerbuilder version 2021 build 1311.

Jeferson Neves Accepted Answer Pending Moderation
  1. Saturday, 26 February 2022 11:21 AM UTC
  2. PowerBuilder
  3. # 1

Hi guys, thank you very much for your attention, problem solved.

The code to delete the icon was 100% correct, the problem was exclusively mine, the application does some operations from time to time, using a timer, which is reset at the beginning of the event and set again at the end of the event. I set the timer to zero before calling the function that deletes the icon and it solved the problem. First time I work with this type of application and I was inattentive.

Comment
  1. Chris Pollach @Appeon
  2. Saturday, 26 February 2022 15:18 PM UTC
Hi Jeferson ... Thanks for letting us know that you resolved the issue. That is great news!

BTW: I just tested my framework Apps on W11 using PB2021 build 1506 & the System Tray code still works 100% in that platform! ;-)
  1. Helpful
There are no comments made yet.
Jeferson Neves Accepted Answer Pending Moderation
  1. Thursday, 24 February 2022 17:56 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Jeferson - 

Does your application issue a Shell_NotifyIconW Windows API call with the proper argument values to delete the icon from the system tray when the app is closing?

I recommend you examine Roland Smith's excellent free code sample program "IconTray":

https://www.topwizprogramming.com/freecode_icontray.html

Specifically, check the m_exit user event in the w_main window and the of_delete_icon object function in the n_icontray non-visual object.

Good luck!

 

Hi, grateful for your attention
I use Shell_NotifyIconW and i believe the code was based on Roland Smith's example (I'm working on this application, but i didn't start the project...).
The application only has a login screen, after logging in, this screen is closed and only the icon remains in the system tray, to exit the application, use the exit menu (of_delete_icon function), which has the code below:

NOTIFYICONDATA lstr_data

lstr_data.cbSize	= NOTIFYICONDATA_SIZE  //constant with value 88
lstr_data.hWnd		= Handle(aw_window)
lstr_data.uID		= 1

If ab_show Then
	aw_window.Show()
	this.of_SetFocus(aw_window)
End If

Return Shell_NotifyIcon(NIM_DELETE, lstr_data)  //constant with value 2

 

Apparently everything is ok, I didn't find what might be missing.

 

 

Comment
  1. John Fauss
  2. Thursday, 24 February 2022 19:05 PM UTC
They may not be anything "missing"... I don't know. Have you verified the success or failure of this API call? Documentation (URL follows) says it returns a Boolean True if successful, False otherwise.

https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw

Is the icon ID value in the NOTIFYICONDATA structure (the value 1) correct?

I can't debug your code for you, that's something you have to do. Roland's IconTray sample program works, I tried it before before examining it to find how it removes the icon from the System Tray, prior to my initial response to your question. The Shell_NotifyIconW API call with a first argument value of 2 is how you remove an icon from the System Tray, according to the Windows API documentation referenced above.

As a developer, if you utilize code from another source, I think it needs to be your responsibility to learn and understand what the borrowed code does and how it works. I've tried to point you in the right direction, but you need to take it from here.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 24 February 2022 16:05 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Jeferson - 

Does your application issue a Shell_NotifyIconW Windows API call with the proper argument values to delete the icon from the system tray when the app is closing?

I recommend you examine Roland Smith's excellent free code sample program "IconTray":

https://www.topwizprogramming.com/freecode_icontray.html

Specifically, check the m_exit user event in the w_main window and the of_delete_icon object function in the n_icontray non-visual object.

Good luck!

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 24 February 2022 15:50 PM UTC
  2. PowerBuilder
  3. # 4

Hi Jeferson;

   Thus far, I am not having this issue in my STD Framework that supports this feature (since 2015). http://chrispollach.blogspot.com/2015/12/stdif.html

  You can give my example App a try and see if that works in your environment. If so, check out my code vs how you have coded this feature. FYI: https://sourceforge.net/projects/stdfndclass/files/Applications/PowerBuilder/CDPlayer

Entering System Tray ....

 

Restoring / removing from System Tray ...

 

  No icon left in System Tray.

 

Note: I have not tried this System Tray feature in my framework on W11 yet.

Note2: I am using PB2021 build 1506

Note3: The above test was on W10 version 21H2 build 19044.1566

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.