473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

NotifyIcon - changing icon

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
2 9624
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: petterl | last post by:
I have tried to find the error in the code below but I always get " An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object...
0
by: Dick Abram | last post by:
I have a project that uses the NotifyIcon to put an icon in the system tray. At some point in the application I change the .Icon property of the object to another Icon object but instead of changing...
2
by: Derrick | last post by:
I've been working on an application which has a NotifyIcon (system tray icon), and a corresponding ContextMenu. I want to be able to update this menu dynamically. However, when I make changes to...
2
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging...
2
by: Erik Cole | last post by:
There doesn't seem to be a mouseover event for the notifyicon, but I want to fire an event that shows the user an updated status message on mouseover...sort of like hovering over the network icon...
2
by: JR | last post by:
Hi, I need to change the notifyicon in a countdown. after about 3000-5000 times there is an error. Here is all the code. what is wrong please help
5
by: celestialgal86 | last post by:
Hi everyone... I'm a starter at .Net programming, and I need some help. I was asked to develop a console app that will auto-hide the console window and show a system tray icon. And by...
1
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side....
8
by: starrysky | last post by:
I have a program which puts an icon in the notification area and has a menu associated with it available by right clicking on the icon. I want the menu items to be selected by single left clicks but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.