Print Page | Close Window

CXTButton SetIcon GDI Leak

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=15324
Printed Date: 16 November 2024 at 9:59pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTButton SetIcon GDI Leak
Posted By: KSUScott
Subject: CXTButton SetIcon GDI Leak
Date Posted: 08 October 2009 at 10:53pm
I believe I've uncovered a GDI leak in the SetIcon method of CXTButton.  The method calls LoadImage and the icon handle is passed to another overloaded version of SetIcon.  That method makes a copy of the given handle, and the original handle is never destroyed (i.e. via DestroyIcon).  I'm using Xtreme Toolkit Pro Version 9.70.  Has this been addressed in subsequent releases?
Thanks!
Scott 
 
 
BOOL CXTButton::SetIcon(CSize size, LPCTSTR lpszID, LPCTSTR lpszHotID/*=NULL*/, BOOL bRedraw/*=TRUE*/)
{
 HICON hIcon = NULL;
 HICON hIconHot = NULL;
 // Free previous resources (if any).
 CleanUpGDI();
 // Find the resource for the normal icon and load the image.
 HINSTANCE hInst = AfxFindResourceHandle(lpszID, RT_GROUP_ICON);
 hIcon = (HICON)::LoadImage(hInst, lpszID,
  IMAGE_ICON, size.cx, size.cy, LR_DEFAULTCOLOR);
 // Return false if the icon handle is NULL.
 if (!hIcon)
 {
  TRACE1( "Failed to load Icon resource %s.\n", lpszID );
  return FALSE;
 }
 // If we are using a pushed image as well...
 if (lpszHotID)
 {
  // Find the resource for the pushed icon and load the image.
  hInst = AfxFindResourceHandle(lpszHotID, RT_GROUP_ICON);
  hIconHot = (HICON)::LoadImage(hInst, lpszHotID,
   IMAGE_ICON, size.cx, size.cy, LR_DEFAULTCOLOR);
  // Return false if the icon handle is NULL.
  if (!hIconHot)
  {
   TRACE0( "Failed to load Icon resource.\n" );
   return FALSE;
  }
 }
 return CXTButton::SetIcon(size, hIcon, hIconHot, bRedraw);
}
 


-------------
Product: Xtreme Toolkit Pro Version 9.70
Platform: Windows (32bit)
Language: Visual C++ 6.0



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net