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()
With Me
.Height = 300
.Width = 650
.Arrangement = Arrange.Vertical
.Padding = 5
End With
With Label1 = New Label(Me) As "Label1"
.Expand = True
.Height = 28
.Font.Size = 60
.Font.Bold = True
.Alignment = Align.Center
End With
With TrayIcon1 = New TrayIcon As "TrayIcon1"
.Tooltip = "Connected"
.Picture = Picture["icon:/22/connect"]
End With
With TrayIcon2 = New TrayIcon As "TrayIcon2"
.Tooltip = "Not Connected"
.Picture = Picture["icon:/22/close"]
End With
With Timer1 = New Timer As "Timer1"
.Delay = 3000
.Trigger
.Start
End With
End
Public Sub Timer1_Timer()
If bSwitch = False Then
TrayIcon1.Show
TrayIcon2.Hide
TrayIcon1.Tooltip = "Connected"
Label1.Text = "Connected"
Else
TrayIcon1.Hide
TrayIcon2.Show
TrayIcon1.Tooltip = "Not connected"
Label1.Text = "Not connected"
End If
bSwitch = Not bSwitch
End
Public Sub Form_Close()
TrayIcon1.Delete 'This stops the program from continuing to run
End