<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : CXTButton SetIcon GDI Leak</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Controls : CXTButton SetIcon GDI Leak]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 13 May 2026 05:02:30 +0000</pubDate>
  <lastBuildDate>Thu, 08 Oct 2009 22:53:16 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=15324</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[CXTButton SetIcon GDI Leak :    I believe I&amp;#039;ve uncovered...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=15324&amp;PID=53726&amp;title=cxtbutton-seticon-gdi-leak#53726</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2985">KSUScott</a><br /><strong>Subject:</strong> 15324<br /><strong>Posted:</strong> 08 October 2009 at 10:53pm<br /><br /><DIV></DIV><DIV></DIV><DIV></DIV><DIV>I believe I've uncovered a GDI leak in the SetIcon method of CXTButton.&nbsp; The method calls LoadImage and the icon handle is passed&nbsp;to&nbsp;another overloaded version of SetIcon.&nbsp; That method makes&nbsp;a copy of&nbsp;the given handle, and the original handle is never destroyed (i.e. via DestroyIcon).&nbsp; I'm using Xtreme Toolkit Pro Version 9.70.&nbsp; Has this been addressed in subsequent releases?</DIV><DIV>Thanks!<BR>Scott&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>BOOL CXTButton::SetIcon(CSize size, LPCTSTR lpszID, LPCTSTR lpszHotID/*=NULL*/, BOOL bRedraw/*=TRUE*/)<BR>{<BR>&nbsp;HICON hIcon = NULL;<BR>&nbsp;HICON hIconHot = NULL;</DIV><DIV>&nbsp;// Free previous resources (if any).<BR>&nbsp;CleanUpGDI();</DIV><DIV>&nbsp;// Find the resource for the normal icon and load the image.<BR>&nbsp;HINSTANCE hInst = AfxFindResourceHandle(lpszID, RT_GROUP_ICON);<BR>&nbsp;<strong>hIcon = (HICON)::LoadImage(hInst, lpszID,<BR>&nbsp;&nbsp;IMAGE_ICON, size.cx, size.cy, LR_DEFAULTCOLOR);</strong></DIV><DIV>&nbsp;// Return false if the icon handle is NULL.<BR>&nbsp;if (!hIcon)<BR>&nbsp;{<BR>&nbsp;&nbsp;TRACE1( "Failed to load Icon resource %s.\n", lpszID );<BR>&nbsp;&nbsp;return FALSE;<BR>&nbsp;}</DIV><DIV>&nbsp;// If we are using a pushed image as well...<BR>&nbsp;if (lpszHotID)<BR>&nbsp;{<BR>&nbsp;&nbsp;// Find the resource for the pushed icon and load the image.<BR>&nbsp;&nbsp;hInst = AfxFindResourceHandle(lpszHotID, RT_GROUP_ICON);<BR>&nbsp;&nbsp;hIconHot = (HICON)::LoadImage(hInst, lpszHotID,<BR>&nbsp;&nbsp;&nbsp;IMAGE_ICON, size.cx, size.cy, LR_DEFAULTCOLOR);</DIV><DIV>&nbsp;&nbsp;// Return false if the icon handle is NULL.<BR>&nbsp;&nbsp;if (!hIconHot)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;TRACE0( "Failed to load Icon resource.\n" );<BR>&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;}<BR>&nbsp;}</DIV><DIV>&nbsp;return CXTButton::SetIcon(size, <strong>hIcon</strong>, hIconHot, bRedraw);<BR>}</DIV><DIV><strong></strong>&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 08 Oct 2009 22:53:16 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=15324&amp;PID=53726&amp;title=cxtbutton-seticon-gdi-leak#53726</guid>
  </item> 
 </channel>
</rss>