StatusBar Icon can't Switch

A

Anony

Hi All,

I have two icons:
Private micoIcon1 As New
System.Drawing.Icon(System.IO.Path.Combine(Application.StartupPath,
"Icon1.ico"))
Private micoIcon2 As New
System.Drawing.Icon(System.IO.Path.Combine(Application.StartupPath,
"Icon2.ico"))

I want switch them:
Private Sub SwitchIcons()
With sbpIcon 'this is the StatusBar Panel name
If .Icon = micoIcon1
.Icon = micoIcon2
Else
.Icon = micoIcon1
End If
End With
End Sub

This works in case of SysTray icon, but not for StatusBar Panel (always
remain micoIcon1). I think I missed something to use the StatusBar Panel.
Can someone tell what's wrong or missed?


Thanks for any tips,
Anony
 
K

Ken Tucker [MVP]

Hi,

Use Equals instead of is.


Private Sub SwitchIcons()
With sbpIcon 'this is the StatusBar Panel name
If .Icon.Equals( micoIcon1) then
.Icon = micoIcon2
Else
.Icon = micoIcon1
End If
End With
End Sub


Ken
-----------------------
Hi All,

I have two icons:
Private micoIcon1 As New
System.Drawing.Icon(System.IO.Path.Combine(Application.StartupPath,
"Icon1.ico"))
Private micoIcon2 As New
System.Drawing.Icon(System.IO.Path.Combine(Application.StartupPath,
"Icon2.ico"))

I want switch them:
Private Sub SwitchIcons()
With sbpIcon 'this is the StatusBar Panel name
If .Icon = micoIcon1
.Icon = micoIcon2
Else
.Icon = micoIcon1
End If
End With
End Sub

This works in case of SysTray icon, but not for StatusBar Panel (always
remain micoIcon1). I think I missed something to use the StatusBar Panel.
Can someone tell what's wrong or missed?


Thanks for any tips,
Anony
 
A

Anony

Thanks Ken,

I tried Equals instead of Is, but nothing changed.
The .Icon.Equals( micoIcon1) seems always return False
 
A

Anony

Thanks Ken,

I tried Equals instead of Is, but nothing changed.
The .Icon.Equals( micoIcon1) seems always return False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top