Notify Icon implementation problem.

G

Guest

Hi I have an application developed with visual studio 2005 which runs
minimized all the time. I needed a notify icon to show up any time app is
running.
So I have used ‘Shell_NotifyIcon’ implementation and its working in basic
terms.

Right now I am able to display the icon at the system tray (notification
area), but I am not able to change the icon using ‘Shell_NotifyIcon’
function. What is actually happening is, the new icon I am trying to change
to shows up on the tray but momentarily. If I launch any other application
and go back to the today screen my icon is disappears. Although the
placeholder for the icon still active (I can still launch application by
clicking the empty placeholder, just the icon not there!)

What I found out so far is, the icon stays on the tray only if the icon is
loaded from the application’s icon ‘LoadIcon(GetModuleHandle(Nothing),
"#32512")’

For some reason the managed icons not working??
Any idea, suggestions

Thanks
 
P

Peter Foot [MVP]

A managed icon's handle is not safe to be used in this way. You should
consider adding multiple native icon resources to your application and using
LoadIcon to retrieve them. You'll have to use a resource editor to embed
multiple icons in this way. .ico files stored as embedded resources in a
managed exe or dll are not stored as Win32 icon resources.

Peter
 
P

Peter Foot [MVP]

Alternatively (If you are using Pocket PC) use the
Microsoft.WindowsCE.Forms.Notification component which will place a
notification icon in the system tray (top bar)

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility
 
G

Guest

Thanks Peter for the reply,
Yes I understand what you are suggesting.
But then, How do I add native resource to a dotnet application? You mean
adding the icons to the dotnet exe using some other tool? Appreciate any info
as to how to do that.
Thanks
 
P

Peter Foot [MVP]

You can do it with Visual Studio, but its a manual process separate from the
project build. You have to open your compiled .exe in a new instance of
Visual Studio (using File > Open > File). It will open the exe and show
embedded resources. You can then right-click the Icon folder and select Add
Resource, click Import... and select Icons from the drop down list and
select your icon file. You can then edit the properties to change the ID.
You'd need to do this manually after each build. There is probably a way to
automate this using MSBuild if you are so inclined.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility
 
G

Guest

Thanks Peter for the suggestions
For now I am going with the 'Notification' implementation. But only one
issue with this method is, ‘Notification’ Space is used by my application all
the time and the left soft key always shows the 'Notification' overriding the
users customized left key as long as my app is running in the today screen.

Thanks again
 

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