473,573 Members | 5,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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.ic o")
End If
Catch ex As Exception
End Try
End Sub
Nov 21 '05 #1
2 9641
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.Reflecti on.Assembly
p = System.Reflecti on.Assembly.Get ExecutingAssemb ly()
Icons(0) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"GreenBulb.ico" ))
Icons(2) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"RedBulb.ic o"))
Icons(1) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"YellowBulb.ico "))

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

I hope this helps
Chris
"Amjad" <Am***@discussi ons.microsoft.c om> wrote in message
news:1F******** *************** ***********@mic rosoft.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(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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.ic o")
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.Reflecti on.Assembly.Get ExecutingAssemb ly(), 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.Reflecti on.Assembly
p = System.Reflecti on.Assembly.Get ExecutingAssemb ly()
Icons(0) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"GreenBulb.ico "))
Icons(2) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"RedBulb.ico") )
Icons(1) = New System.Drawing. Icon(p.GetManif estResourceStre am(Me.GetType() ,
"YellowBulb.ic o"))

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
1583
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 reference not set to an instance of an object." and then
0
1308
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 the tray icon to the new Icon a new icon appears in the system tray next to the original icon and the new icon will not resond to any events. Has...
2
2911
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 the menu, it seems to disappear. This only breaks when the context menu is tied to a NotifyIcon - not to any other control. Below is a C# file...
2
2636
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 services via email and a customized event log viewer. An additional goal is to have the service provide a visual status indicator via an icon to be located...
2
3915
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 shows bytes sent & received. Anyone know how to pull this off? Thanks!
2
2129
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
2889
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 default, the system tray icon on click is supposed to show the console window I know window apps are usually the better solution for handling NotifyIcon...
1
4284
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. From your codes, I think the logical is, every time the Timer's elapsed event fires, we call the Check_For_Version_Update() function. From the...
8
8476
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 I also want the user to be able to single left click on the icon itself to do some other functionality. Here's the problem - the single click on...
0
7792
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7709
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8218
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6435
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1049
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.