I was able to swap Icons, both using the Resources example and this
approach:
string str1 = @"C:\Data\My Stuff\Images\Cars\untitled.bmp";
string str2 = @"C:\Data\My Stuff\Documents\ebay.txt";
bool flip;
void button1_Click(object sender, EventArgs e) {
if (flip)
notifyIcon1.Icon =
System.Drawing.Icon.ExtractAssociatedIcon(str1);
else
notifyIcon1.Icon =
System.Drawing.Icon.ExtractAssociatedIcon(str2);
flip = !flip;
}
Of course you could just load up the icon using the constructor, but I
didn't have any icon files available. The important part is that I'm
doing it when you click the button, and I'm setting the Icon property
of the NotifiyIcon object.
On Sep 6, 10:51 am, mrkoconnell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was experimenting with thisiconproblem and had a very difficult
> time attempting to reload anothericonfile for aNotifyIconcontrol.
> My problem was that I kept getting involved with the resouce file
> which is very extensive and written in xml. After about an hour of
> messing with this, I can up with a much simpler solution.
>
> I added twoNotifyIconcontrols and simply swapped the visible state
> (true or false) between the two icons. This worked very well.
>
> If you find another way involving reassigning theiconto a simple
> control, I am very interested in hearing how you did it.
>
> Thanks,
>
> Kevin O'Connell
>
> On Aug 29, 9:00 am, Kevin Hunter <[EMAIL PROTECTED]> wrote:
>
> > OK, here is my problem
>
> > i am currently making a program that involves aNotifyIcon. i can
> > manly change theicon(before the program runs in the properties
> > window) with no problem, but what i need is a way to have the program
> > change itsiconmid-stream.
>
> > i have already make toiconfiles: let's call them icon1.ico and
> > icon2.ico. i also have a (working)NotifyIcon, and we'll call that
> > NotifyIcon1 (these are all default names).
>
> > i have tried other things like NotifyIcon1.add("TheIconLocation"),
> > but that just ADDS the newiconto the notification area, and will not
> > replace the previous one.
>
> > so in short: is there a way to code a program to replace oniconin an
> >NotifyIconwith another?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---