By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

NotifyIcon - changing icon

P: n/a
Hi,
I'm using the NotifyIcon to process some text files in the background
periodically. I want to display one icon in the task bar when the program is
in stand by mode, and I want to display another icon when it is in processing
mode. How can I do that? I have some pseudo code below:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Try
If processing Then
NotifyIcon.Text = "Processing .."
NotifyIcon.Icon = New Icon("Busy.ico") 'the problem is here,
I added the icon file to the solution explorer, but it's not using it!
Else
NotifyIcon.Text = "Standing By"
NotifyIcon.Icon = New Icon("Normal.ico")
End If
Catch ex As Exception
End Try
End Sub
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The way I did it was as follows...

Have an array of icons:
Dim Icons(2) As System.Drawing.Icon

Have your icons set as embedded (so they go into the resource file). Select
the icon in solution explore and change the build action to embedded.
Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Icons(0) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"GreenBulb.ico"))
Icons(2) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"RedBulb.ico"))
Icons(1) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"YellowBulb.ico"))

Then change the icon as you need it.
ntfSystemInfo.Icon = Icons(Counter)

I hope this helps
Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Hi,
I'm using the NotifyIcon to process some text files in the background
periodically. I want to display one icon in the task bar when the program
is
in stand by mode, and I want to display another icon when it is in
processing
mode. How can I do that? I have some pseudo code below:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Try
If processing Then
NotifyIcon.Text = "Processing .."
NotifyIcon.Icon = New Icon("Busy.ico") 'the problem is
here,
I added the icon file to the solution explorer, but it's not using it!
Else
NotifyIcon.Text = "Standing By"
NotifyIcon.Icon = New Icon("Normal.ico")
End If
Catch ex As Exception
End Try
End Sub

Nov 21 '05 #2

P: n/a
Chris,

What advantage is it for an Icon to be in the resource file? Isn't
the resource file just a list of files for the solution/project?
Seems like if anything I would want the icon file inside the .exe
file. When I add an icon (from p =
System.Reflection.Assembly.GetExecutingAssembly(), build action
embedded) it doesn't change the size of the .exe file.

Thanks...
Forrest

On Wed, 22 Dec 2004 11:17:38 -0600, "Chris, Master of All Things
Insignificant" <chris@No_Spam_Please.com> wrote:
The way I did it was as follows...

Have an array of icons:
Dim Icons(2) As System.Drawing.Icon

Have your icons set as embedded (so they go into the resource file). Select
the icon in solution explore and change the build action to embedded.
Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Icons(0) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"GreenBulb.ico"))
Icons(2) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"RedBulb.ico"))
Icons(1) = New System.Drawing.Icon(p.GetManifestResourceStream(Me .GetType(),
"YellowBulb.ico"))

Then change the icon as you need it.
ntfSystemInfo.Icon = Icons(Counter)

I hope this helps
Chris

< snip >

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.