🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Assigning Icon from ExtractIconEx without leaks

#189
From: Mike Collins
Date: Wed, 02 Jul 2008 00:15
63 lines
3155 bytes
Hay Remy - it's not directly connected but just reply has just prompted me 
to look at the system tray balloon tip icon problem that I posted about the 
other week.

If you remember, I was having an issue with the balloon tip not being 
displayed correctly.

I've just looked over my code for setting the balloon tip icon (which I've 
shown below).  After I've loaded the required icon, and sent the 
Shell_NotifyIcon() notification, i delete the loaded icon using 
DestroyIcon().  based on what you have just explained, could this possibly 
be the cause of my problem?  I've looked over some other examples on the net 
and i can't find any code examples where they destroy the icon like i 
have...

Any thoughts?

Mike


bool TMainForm::SetBalloonTip(const AnsiString &p_szTitle, const AnsiString 
&p_szBody, DWORD p_dwIcon,
                              UINT p_uTimeout, bool p_bRespondUClick)
{
   bool bRtn = false;
   if (bTrayIconActive)
   {
      EnterCriticalSection(&csIPCCallBack);
      try
      {
         HICON hIcon = NULL;
         if ((p_dwIcon >= NIIF_NONE) && (p_dwIcon <= NIIF_ERROR))
         {
            nid.uFlags      = NIF_INFO;
            nid.dwInfoFlags = p_dwIcon;
         }
         else
         {
            nid.uFlags      = NIF_INFO | NIF_ICON;
            nid.dwInfoFlags = NIIF_USER;
            hIcon           = (HICON)Utils->RtnIcon(p_dwIcon, 16); // 
LR_DEFAULTCOLOR);
            nid.hIcon       = hIcon;
         }
         nid.uTimeout = (p_uTimeout * 1000); // convert time to ms
         lstrcpyn(nid.szInfoTitle, p_szTitle.c_str(), 
MAX_TRAY_BALLOON_TITLE);
         lstrcpyn(nid.szInfo, p_szBody.c_str(), MAX_TRAY_BALLOON_BODY);
         if (bRtn = (bool)Shell_NotifyIcon(NIM_MODIFY, &nid))
         {
            lstrcpyn(nid.szInfoTitle, "\0", MAX_TRAY_BALLOON_TITLE);
            lstrcpyn(nid.szInfo, "\0", MAX_TRAY_BALLOON_BODY);
         }
         if (hIcon)
            ::DestroyIcon(hIcon);
      }
      __finally
      {
         LeaveCriticalSection(&csIPCCallBack);
      }
   }
   return bRtn;
}
Technical Details
Message-ID: <486ab7ec@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <486a1911@newsgroups.borland.com> <486a5c9e$1@newsgroups.borland.com> <486aa96e@newsgroups.borland.com> <486aaff6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,dea519f40adb32bd
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <486a1911@newsgroups.borland.com> <486a5c9e$1@newsgroups.borland.com> <486aa96e@newsgroups.borland.com> <486aaff6$1@newsgroups.borland.com>
Subject: Re: Assigning Icon from ExtractIconEx without leaks
Date: Wed, 2 Jul 2008 00:15:54 -0000
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133
NNTP-Posting-Host: 89.242.18.71
Message-ID: <486ab7ec@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1214953452 89.242.18.71 (1 Jul 2008 16:04:12 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail