Print Page | Close Window

LoadBitmapFromResource finds wrong resource

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=19399
Printed Date: 18 June 2025 at 5:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: LoadBitmapFromResource finds wrong resource
Posted By: rdhd
Subject: LoadBitmapFromResource finds wrong resource
Date Posted: 11 January 2012 at 5:30pm
When I add PNG and BMP resources to my project the IDE separates the two types of images in the resource view. I have a "Bitmap" and a "PNG" entry. So far so good.
 
But the IDE can assign the same resource ID to a BMP and a PNG resource. When I call CXTPImageManager::SetIcons, LoadBitmapFromResource is called. There I see this:
 

hModule = AfxFindResourceHandle(lpszResource, _T("PNG"));

When I am debugging, I see that even if I pass in an ID that is used only on a BMP resource, the call succeeds. Hence, when I am trying to load a BMP resource for which a PNG resource has been assigned the same ID, the image manager will load the PNG and not the BMP and that can cause problems since the wrong image has been loaded.
 
My only work-around appears to be to manually edit the values in resource.h. Is there a better way?



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