ForeverNoob wrote: ↑
Thursday 28th January 2021 3:58pm
OK, this is what I'm going to do: I'll create 2 TrayIcons, each with it's own icon, and just hide or show the relevant one as needed. No use fighting what looks like a bug somewhere.
Thank you all for the time and effort.
You're a genius, and it works. Here my modified code.
' Gambas class file
bSwitch As Boolean
Timer1 As Timer
TrayIcon1 As Trayicon
TrayIcon2 As Trayicon
Label1 As Label
Public Sub Form_Open()
.Height = 300
.Width = 650
.Arrangement = Arrange.Vertical
.Padding = 5
With Label1 = New Label(Me) As "Label1"
.Expand = True
.Height = 28
.Font.Size = 60
.Font.Bold = True
.Alignment = Align.Center
With TrayIcon1 = New TrayIcon As "TrayIcon1"
.Tooltip = "Connected"
.Picture = Picture["icon:/22/connect"]
With TrayIcon2 = New TrayIcon As "TrayIcon2"
.Tooltip = "Not Connected"
.Picture = Picture["icon:/22/close"]
With Timer1 = New Timer As "Timer1"
.Delay = 3000
Public Sub Timer1_Timer()
If bSwitch = False Then
TrayIcon1.Tooltip = "Connected"
Label1.Text = "Connected"
TrayIcon1.Tooltip = "Not connected"
Label1.Text = "Not connected"
bSwitch = Not bSwitch
Public Sub Form_Close()
TrayIcon1.Delete 'This stops the program from continuing to run