System Tray Icon

B

bic

Alex, from IntelliProg Inc. has an excellent article on how to put an
Icon onto the systemTray on the PocketPC here. The program works fine
if you have icon that's 16x16 but when you have icons ie.. 32x32.. it
will not display any image on the systemTray.. anyone know how to fix
this problem?


This line that load the icon is

IntPtr hIcon = LoadIcon(GetModuleHandle(null), "#32512");
notifyIcon.Add(hIcon);


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/messagewindow.asp
 
P

Peter Foot [MVP]

If you create an icon which has multiple image sizes (16x16 and 32x32) and
set this as your application icon then this should work as expected with the
32x32 used in the Programs screen and the 16x16 used in the tray.

Peter

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

bic said:
Alex, from IntelliProg Inc. has an excellent article on how to put an
Icon onto the systemTray on the PocketPC here. The program works fine
if you have icon that's 16x16 but when you have icons ie.. 32x32.. it
will not display any image on the systemTray.. anyone know how to fix
this problem?


This line that load the icon is

IntPtr hIcon = LoadIcon(GetModuleHandle(null), "#32512");
notifyIcon.Add(hIcon);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/messagewindow.asp
 
B

bic

Peter Foot said:
If you create an icon which has multiple image sizes (16x16 and 32x32) and
set this as your application icon then this should work as expected with the
32x32 used in the Programs screen and the 16x16 used in the tray.

Peter

Well, it doesn't that why I am asking.. I have 16x16 and 32x32.. I
have have multiple/single 16x16 it works fine but if I introduce any
32x32.. it fails to load on the systems tray..

BTW.. this is the VB.NET version.. I converted Alex project to vb.net.
 
T

Thomas

The example does not handle the composite icon very well... I just
converted it to a 16x16 icon only to solve the problem (I do not need
the 32x32 so that's not an issue).

But here's an issue that's a little bit trickier:

The example found on Microsofts site shows a messagebox when the user
clicks on the tray icon, thus also showing the form...

But I do not wish to have a messagebox, I just want to show the
application (form) when the user clicks the icon...

How do I do this? There's no this.activate() in CF and I've tried
everything else that I could come up with (resizing, windowstate,
focus,show,refresh... you name it).

Anyone ?

// Thomas
 
P

Paul G. Tobey [eMVP]

I have not tried this in CF, but if you can get the window handle of your
form, you should be able to call

ShowWindow( formhwnd, SW_SHOWNORMAL );
SetForegroundWindow( formhwnd );

by P/Invoking those two functions. This is what I do in my native-code
applications to bring a window to the front in response to a double-click on
the tray icon.

Paul T.
 
G

Guest

I am seeing the same thing. How can I get the icon to show up in the tray? If you don't have the 32x32 icon it will not look right in the programs folder. Any help would be great. Ex. How can you load an embedded icon. That way I can have a 16x16 icon embedded in the app that I can use just for the sys tray. Thanks

----- Peter Foot [MVP] wrote: ----

If you create an icon which has multiple image sizes (16x16 and 32x32) an
set this as your application icon then this should work as expected with th
32x32 used in the Programs screen and the 16x16 used in the tray

Pete

--
Peter Foo
Windows Embedded MV
OpenNETCF.org Senior Adviso
www.inthehand.com | www.opennetcf.or

bic said:
Alex, from IntelliProg Inc. has an excellent article on how to put a
Icon onto the systemTray on the PocketPC here. The program works fin
if you have icon that's 16x16 but when you have icons ie.. 32x32.. i
will not display any image on the systemTray.. anyone know how to fi
this problem
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/messagewindow.as
 
B

bic

Bobby Cannon said:
I am seeing the same thing. How can I get the icon to show up in the tray? If you don't have the 32x32 icon it will not look right in the programs folder. Any help would be great. Ex. How can you load an embedded icon. That way I can have a 16x16 icon embedded in the app that I can use just for the sys tray. Thanks.

I was considering that.. but I have read somewhere here.. that this is
a problem getting the pointer to the icon..
 
P

Peter Foot [MVP]

I created a single icon file with both 16x16 and 32x32 icons (to tell them
apart they have the text 16 and 32 respectively). I installed the exe to the
\Windows\Start Menu\Programs folder - the 32x32 icon is used correctly.
Within the app I create a tray icon (this is not using Alex's code but a
beta OpenNETCF release - however the same technique is used to load the
executing apps default icon) - the 16x16 image is displayed in the tray on
the Today screen.
The icon editor in Visual Studio is not always most intuitive. For this to
work you must have a single ico file with the two images (not add multiple
embedded icons to the project), this file must be specified in the
ApplicationIcon property on the project properties dialog. Any icons added
to the project as embedded resources are not stored as Win32 icons so are
not accessible from native API functions e.g. LoadIcon().

Peter

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

bic said:
Bobby Cannon <[email protected]> wrote in message
tray? If you don't have the 32x32 icon it will not look right in the
programs folder. Any help would be great. Ex. How can you load an embedded
icon. That way I can have a 16x16 icon embedded in the app that I can use
just for the sys tray. Thanks.
 
G

Guest

Come on give us some credit. I know the icon has to be one file with both formats. Can you give us the code you used or a link. Maybe even a project to download? Give us something....
 
C

Chris Tacke, eMVP

G

Guest

This is exactly what I am talking about except there's no CODE. We know what an ICON is. We know that an icon can hold many formats ( 16x16, 32x32 ). But I went ahead and downloaded the MS example http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/messagewindow.asp and the sample icon from http://blog.opennetcf.org/pfoot/PermaLink.aspx/bc8a9304-112d-4fb7-b9f7-512f62e2d8df and tried to use them together. Guess what.... it doesn't work. I have tested in on my hp1910 and the emulator. The icon is there but there is a no icon in the bar just a "invisible" spot. The only reason I know it's there is because the example has a messagebox that pops up when you click it. Anyway..... any ideas...........

I don't mean to be rude but I am very frustrated at the whole .net compact framework.

----- Chris Tacke, eMVP wrote: -----

Like this?

http://blog.opennetcf.org/pfoot/PermaLink.aspx/bc8a9304-112d-4fb7-b9f7-512f62e2d8df


--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Bobby Cannon said:
Come on give us some credit. I know the icon has to be one file with both
formats. Can you give us the code you used or a link. Maybe even a project
to download? Give us something....
 
G

Guest

This works:
string szPath = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
ExtractIconEx(szPath, 0, 0, ref hIcon, 1);

This doesn't:
// This will not display the 16x16 icon, can't explain why?
hIcon = LoadIcon( GetModuleHandle(null), name );

I also found something real interesting with the "transparent" color. I thought the "darkesh green" was the transparent color for icons. Seems that it works great when the 16x16 icon is displayed in the systray but when displayed on the startmenu the transparent color will change to black. Then I saw the "Pinkish" color in the VS icon editor right under your current selected color so I thought um lets try that. Sure enough it may the startmenu dislpay the transparent background but yep you guest it. It broke the tray menu from displaying transparent. It changed the transparent color to black. This is very annoying.
 

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