Hello Everyone,

While using my htc touch a few weeks ago, I noticed small icons towards the
bottom of the screen. In desktop apps I used the NotifyIcon control. I have
read that is control is not support in the CF. How was that Icon displayed?

-James

Re: System tray icon by BogusID

BogusID
Wed Mar 05 22:19:21 CST 2008

"James" <james_devitt@hotmail.comi> wrote:
>Hello Everyone,?`While using my htc touch a few weeks ago, I noticed small
icons towards the tbottom of the screen. In desktop apps I used the NotifyIcon
control.


<http://www.codeguru.com/forum/archive/index.php/t-194324.html>

Johan ran into this and was nice enough to tell how he solved it.
Thanks to "Johan" from 2002...

The system tray doesn't seem to support LoadIcon()
You have to use LoadImage() instead.


Re: System tray icon by Christopher

Christopher
Thu Mar 06 04:35:21 CST 2008

Hi,

"James" <james_devitt@hotmail.comi> wrote in message
news:0BCD1F58-A799-4A07-80D1-7FE720772E68@microsoft.com...
> In desktop apps I used the NotifyIcon control. I have read that is control
> is not support in the CF. How was that Icon displayed?

You are correct. The functionality is present within the native OS in the
form of the Shell_NotifyIcon API, but the .NET Compact Framework does not
provide a wrapper around it.

This means you have to use Platform Invoke functionality to access the
native API, essentially creating your own class that parallels the
NotifyIcon class from the desktop framework.

There are a couple of examples available which demonstrate doing this
(although many can be simplified a little now, since they were originally
written for .NET CF 1.0).

See for example Alex Yakhnin's "Using the Microsoft .NET Compact Framework
MessageWindow class" article available on MSDN at
http://msdn2.microsoft.com/en-us/library/aa446525.aspx.

Hope this helps,
Christopher Fairbairn



Re: System tray icon by Christopher

Christopher
Thu Mar 06 05:00:08 CST 2008

Hi,

"Christopher Fairbairn" <christopher@christec.co.nz> wrote in message
news:uC5qIX3fIHA.748@TK2MSFTNGP04.phx.gbl...
> See for example Alex Yakhnin's "Using the Microsoft .NET Compact Framework
> MessageWindow class" article available on MSDN at
> http://msdn2.microsoft.com/en-us/library/aa446525.aspx.

I guess I should also point out that OpenNETCF's Smart Device Framework
(SDF) library contains an OpenNETCF.Windows.Forms.NotifyIcon class. This
class provides you a prebuilt class that parallels the one found on the
desktop.

The community edition of the SDF library is available for free. See
http://www.opennetcf.com/Products/SmartDeviceFramework/CommunityEdition/tabid/67/Default.aspx
for more information.

Hope this helps,
Christopher Fairbairn



Re: System tray icon by James

James
Thu Mar 06 14:47:45 CST 2008

Thanks again Christopher, I have taken a look at your sources and have used
the MSDN link below. I downloaded Alex's NotifyIcon.cs class and made the
Image change.

Added reference to the newly compiled dll and Imported it.
Created a Noty object based on the NotifyIcon class (withevents).
Added a form Load and Closing events where I run Noty.add and Noty.remove.

The system tray shows my icon, just as I had seen it prior. The only problem
is that it disappears after the first use? After checking everything I
realized my Icon object was went out of scope and resulted in a null icon -
Added an global Icon object from my .ico file and problem solved!

Thanks for the link!

-James
system tray icon
notifyicon
Shell_NotifyIcon



"Christopher Fairbairn" <christopher@christec.co.nz> wrote in message
news:uC5qIX3fIHA.748@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> "James" <james_devitt@hotmail.comi> wrote in message
> news:0BCD1F58-A799-4A07-80D1-7FE720772E68@microsoft.com...
>> In desktop apps I used the NotifyIcon control. I have read that is
>> control is not support in the CF. How was that Icon displayed?
>
> You are correct. The functionality is present within the native OS in the
> form of the Shell_NotifyIcon API, but the .NET Compact Framework does not
> provide a wrapper around it.
>
> This means you have to use Platform Invoke functionality to access the
> native API, essentially creating your own class that parallels the
> NotifyIcon class from the desktop framework.
>
> There are a couple of examples available which demonstrate doing this
> (although many can be simplified a little now, since they were originally
> written for .NET CF 1.0).
>
> See for example Alex Yakhnin's "Using the Microsoft .NET Compact Framework
> MessageWindow class" article available on MSDN at
> http://msdn2.microsoft.com/en-us/library/aa446525.aspx.
>
> Hope this helps,
> Christopher Fairbairn
>