Notification icons

  • Thread starter Thread starter Jon Skeet [C# MVP]
  • Start date Start date
J

Jon Skeet [C# MVP]

I've seen the OpenNETCF Notification class, which doesn't allow the
developer to specify the icon to display. I would like to use a
notification icon which changes based on the state of the app - like
the phone symbol does. Has anyone done this before, and if not, is it
likely to be a simple modification to the OpenNETCF library?
 
I think that what you want is OpenNETCF.Windows.Forms.NotifyIcon in the SDF
(notifyicon.cs).

Paul T.
 
What you'll need to do (and I'll make this change to the code at some point
honest :-)) is to place your icons into a native dll or native exe (since
managed resources are stored differently). You can then use the LoadIcon API
function to get a HICON for the icon resource. You can then apply this to
the Notification Bubble or OpenNETCF.Windows.Forms.NotifyIcon with some
minor tweaking of the code.
The problem is there is no method to get an icon handle from a managed Icon
object in .NETCF, so I can;t simply create an Icon property for these
controls. However it's my intention to at least expose a property for the
IconHandle (IntPtr) so you can assign any native icon of your choosing to
the object. By default we grab the icon of the calling exe.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
<"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com> said:
I think that what you want is OpenNETCF.Windows.Forms.NotifyIcon in the SDF
(notifyicon.cs).

No, that still only seems to use a single icon - there's no way of
saying which icon to use.

I definitely want the OpenNETCF.Notification.NotificationEngine type of
notification though, because I also want the user to be able to click
on the icon and get options to do other things - that's the next step
after being able to use different icons.
 
Hmmm. It's commented-out, but the Icon property in the NotifyIcon class
seems to be what you want, although, as Peter noted, you have to get a
native icon handle somehow. If you can get the handle somehow (using a
resource DLL built from eVC, maybe), you should be able to change the icons
with a relatively small change to the NotifyIcon class.

It appears to me that the current version of the source (at least the latest
in source control), *does* notify the class when things like double-clicks
happen to the icon.

Paul T.

Jon Skeet said:
<"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com> said:
I think that what you want is OpenNETCF.Windows.Forms.NotifyIcon in the
SDF
(notifyicon.cs).

No, that still only seems to use a single icon - there's no way of
saying which icon to use.

I definitely want the OpenNETCF.Notification.NotificationEngine type of
notification though, because I also want the user to be able to click
on the icon and get options to do other things - that's the next step
after being able to use different icons.
 
<"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
com> said:
Hmmm. It's commented-out, but the Icon property in the NotifyIcon class
seems to be what you want, although, as Peter noted, you have to get a
native icon handle somehow. If you can get the handle somehow (using a
resource DLL built from eVC, maybe), you should be able to change the icons
with a relatively small change to the NotifyIcon class.

Right. Similarly with a change to the Notification class, by the sounds
of it.
It appears to me that the current version of the source (at least the latest
in source control), *does* notify the class when things like double-clicks
happen to the icon.

Yes, but I need more than that - I need the full "balloon" stuff to
tell the user what's going on. It sounds like Notification should be
fine - and I've a colleague who'll need to use NotifyIcon too :)
 
Peter Foot said:
What you'll need to do (and I'll make this change to the code at some point
honest :-)) is to place your icons into a native dll or native exe (since
managed resources are stored differently). You can then use the LoadIcon API
function to get a HICON for the icon resource. You can then apply this to
the Notification Bubble or OpenNETCF.Windows.Forms.NotifyIcon with some
minor tweaking of the code.
The problem is there is no method to get an icon handle from a managed Icon
object in .NETCF, so I can;t simply create an Icon property for these
controls. However it's my intention to at least expose a property for the
IconHandle (IntPtr) so you can assign any native icon of your choosing to
the object. By default we grab the icon of the calling exe.

Right. Knowing that it needs to be a native dll/exe containing the icon
answers my next question, namely how to get other icons into my CF
program :) Presumably I can just create a DLL with no actual code, and
use that...

I'll modify the class to allow the Icon property to be set directly,
and probably also add a helper method which just takes a resource name
and an icon number.

I'll feed the code back when (if!) I get it working.
 
well maybe you can use an imagelist and link it to the notification icon.
That would be easier for the developers.

Peter Foot said:
What you'll need to do (and I'll make this change to the code at some
point honest :-)) is to place your icons into a native dll or native exe
(since managed resources are stored differently). You can then use the
LoadIcon API function to get a HICON for the icon resource. You can then
apply this to the Notification Bubble or
OpenNETCF.Windows.Forms.NotifyIcon with some minor tweaking of the code.
The problem is there is no method to get an icon handle from a managed
Icon object in .NETCF, so I can;t simply create an Icon property for these
controls. However it's my intention to at least expose a property for the
IconHandle (IntPtr) so you can assign any native icon of your choosing to
the object. By default we grab the icon of the calling exe.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Back
Top