CXTButton SetIcon GDI Leak |
Post Reply |
Author | |
KSUScott
Newbie Joined: 08 May 2007 Location: United States Status: Offline Points: 1 |
Post Options
Thanks(0)
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |