Show Icons and Notifications not "sticky" for PB app

Windows specific forum
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Show Icons and Notifications not "sticky" for PB app

Post by harkon »

I wrote a PB app a while back that occasionally scans a folder to see if there is a new file, and if there is proceeds to update a web folder. I have to app start minimized to the system tray, but on Windows restart the icon is in the expanded tray. So I set the application to "Show Icon and Notifications" and now it becomes visible. but on reboot it disappears and I need to redo "Show Icon and Notifications" in the customized view. There ends up being 2 entries for the app, one has an icon and the other does not. Sometimes it does show up on reboot, but mostly it does not. Obviously I'm missing something in how the tray customized view is memorized and how then to allow my application to be properly remembered. The application is just a portable .exe file and has no registry entries. Any thoughts on what I'm missing?
Missed it by that much!!
HK
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: Show Icons and Notifications not "sticky" for PB app

Post by harkon »

This continues to be a problem here. Does anyone know what the mechanism is that Windows uses to capture the display default for an icon in the system tray? I know that in the registry there is an iconstreams subkey under HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify, and I've tried resetting this and re-customizing to my prefs, but every reboot, my app, in particular, is forgotten and defaults to "show only notifications". There is another really odd thing happening and that is when I choose to customize the notification area, my program shows up twice, one with an icon which is set to "Only show notifications", and another which has no icon associated which says to "Show icons and notifications". This tells me that somehow my program is changed upon each startup. Somehow, how the program is identified by Windows to follow the customized system tray settings changes at each reboot. I don't know what the mechanism is that Windows uses to keep track of all of this.

Does anyone have any thoughts at all on this?
Missed it by that much!!
HK
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: Show Icons and Notifications not "sticky" for PB app

Post by oreopa »

Does your app change its tray icon tooltip or perhaps some titlebar text?

I can't remember the exact details, but I recall seeing something similar with some program once or twice on Win7, where there would be multiple entries in the tray customisation control panel window. It was something to do with either the tooltip or window title changing as far as I remember.

That's all I've got, but it might be worth looking into if your app changes some text somewhere.
Proud supporter of PB! * Musician * C64/6502 Freak
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: Show Icons and Notifications not "sticky" for PB app

Post by harkon »

I appreciate the response. Tooltip never changes, but the icon changes depending on what the program is doing. This was driving me nuts, so I spent a good amount of time working on it today. I discovered that I did not have "Create threadsafe executable" checked in the compiler options. The program starts up, opens window, creates a thread catch image for different icons and then minimizes to tray. Tooltip is always empty at this point but hovering . I'm thinking that the thread I opened resulted in a iconless process with the same name and was confusing things. It has been working through a few reboots now. I hope this is the issue.

I remember working with this and doing this without creating a thread, but the nature of the program lended itself well to just scanning for a file in the background. Stupid me, when I moved to doing this in a thread never thought of making the change in compiler options.
Missed it by that much!!
HK
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: Show Icons and Notifications not "sticky" ... [SOLVED]

Post by harkon »

>SOLVED<

It's been a while now and the fact that I didn't have compiler options set to create a threadsafe executable created the problem. Once I recompiled with that option set, it shows up every time.

Thanks to everyone who helped, that one drove me nuts for a while.
Missed it by that much!!
HK
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: Show Icons and Notifications not "sticky" for PB app

Post by harkon »

Thanks for the info. I use;

Code: Select all

Procedure.i Min2Tray(WindowNumber.i, ImageNum.i, ToolTip.s)
  Define TrayIcon.i
  SetWindowState(WindowNumber, #PB_Window_Minimize) 
  TrayIcon=AddSysTrayIcon(#PB_Any, WindowID(WindowNumber), ImageID(ImageNum))
  SysTrayIconToolTip(TrayIcon, ToolTip)
  HideWindow(WindowNumber,1)
  ProcedureReturn TrayIcon
EndProcedure
To minimize to the system tray and ;

Code: Select all

    If TrayIconNum
      ChangeSysTrayIcon(TrayIconNum,ImageID(3))
    EndIf
To change the icon. ImageID changes depending on app status.

This works now that I've allowed for a threadsafe executable. I have not yet tried in Windows 10 though, only in Windows 7. Not sure what you were experiencing or why, unless execution order somehow changed for you.
Missed it by that much!!
HK
Post Reply