🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #472

system tray balloon notifcation issue

#472
From: Mike Collins
Date: Wed, 12 Mar 2008 14:38
48 lines
2900 bytes
Hi all, I posted the message below to the 
microsoft.public.win32.programmer.ui forum but there a bit slack over there 
and never want to share an knowledge.  Just wondering if anyone here has any 
ideas.

// ******************************************************

Just wondering if anyone could help me with a problem / potential bug that 
i'm experiencing.  I have a system tray application that should run when a 
user first logs on.  The application displays Balloon Pop-ups to notify the 
user of certain events.  Within these balloons, I want to display my own 
icons instead of using the default NIIF_ icons. Note, this is for use on 
Windows XP / 2003.

I have three issues / problems.

Firstly, in the documentation, it states that to set a custom icon in a 
balloon you set the dwInfoFlags to NIIF_USER, and then set the hIcon to the 
icon in question.  However when i do this, the icon changes but not to the 
one i specify.  For example, if i set it to be my applicaitons icon, i get 
the wi-fi icon being displayed.  It sees to be the last icon that is shown, 
get's displyed in my balloon.  I resolved it by setting the uFlah i.e. 
uFlags = NIF_INFO | NIF_ICON;

Secondly, when i do this, it causes the system tray icon to change as well. 
The only way i can resolve this issue is to immediatly set the system tray 
icon back to what it was before the balloon was displayed.  This is ok but 
it's a bit sloppy.

Finally, when my application first starts up, i still get the wrong icon 
being displayed in the balloon.

My code looks like this:

         nid.uFlags          = NIF_INFO | NIF_ICON;
         nid.dwInfoFlags = NIIF_USER;
         HICON hIcon   = (HICON)::LoadImage(HInstance, MAKEINTRESOURCE(101), 
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
         nid.hIcon  = hIcon;
         bRtn = (bool)Shell_NotifyIcon(NIM_MODIFY, &nid);
         ::DestroyIcon(hIcon);

Can anyone point me in the write direction here - if there anything obviouse 
that i'm doing wrong here.

Many thanks in advance,

Mike C 
Technical Details
Message-ID: <47d7e8aa$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,61e4cf3ce8a471e2,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: system tray balloon notifcation issue
Date: Wed, 12 Mar 2008 14:38:59 -0000
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133
NNTP-Posting-Host: 89.240.148.143
Message-ID: <47d7e8aa$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1205332138 89.240.148.143 (12 Mar 2008 07:28:58 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail