Missing function SysTrayIconID

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Missing function SysTrayIconID

Post by mk-soft »

Missing SysTrayIconID(#SysTrayIcon) for API functions

Internal not official solution

Code: Select all

Procedure SysTrayIconID(SysTrayIcon)
  Protected *object
  *object = IsSysTrayIcon(SysTrayIcon)
  If *object
    ProcedureReturn PeekI(*object)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Missing function SysTrayIconID

Post by Kwai chang caine »

Thanks for this new function 8)

Is it normal i have two time the same ID ? :shock:

Code: Select all

Procedure SysTrayIconID(SysTrayIcon)
 Protected *object
 *object = IsSysTrayIcon(SysTrayIcon)
 If *object
  ProcedureReturn PeekI(*object)
 Else
  ProcedureReturn 0
 EndIf
EndProcedure

OpenWindow(0, 100, 150, 300, 100, "PureBasic - SysTray Example", #PB_Window_SystemMenu)

IconName$ = #PB_Compiler_Home + "examples/sources/Data/CdPlayer.ico"

AddSysTrayIcon(1, WindowID(0), LoadImage(0, IconName$))
AddSysTrayIcon(2, WindowID(0), LoadImage(1, IconName$))
SysTrayIconToolTip(1, "Icon 1")
SysTrayIconToolTip(2, "Icon 2")

Debug SysTrayIconID(1)
Debug SysTrayIconID(2)

Repeat
 Event = WaitWindowEvent()
 
 If Event = #PB_Event_SysTray
  If EventType() = #PB_EventType_LeftDoubleClick
   MessageRequester("SysTray", "Left DoubleClick on SysTrayIcon "+Str(EventGadget()),0)
   
   ChangeSysTrayIcon (EventGadget(), LoadImage(0, IconName$))
   SysTrayIconToolTip(EventGadget(), "Changed !")
  EndIf
  
 EndIf
Until Event = #PB_Event_CloseWindow
ImageThe happiness is a road...
Not a destination
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Missing function SysTrayIconID

Post by mk-soft »

With Linux and macOS it fits. I don't know under Windows.
Since there is no PB SDK via the Systray, this is without guarantee.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Missing function SysTrayIconID

Post by Kwai chang caine »

Ok thanks :wink:
ImageThe happiness is a road...
Not a destination
Post Reply