|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Krustys Donuts
|
Jul 28, 2008 - 3:31 PM
|
Dear Product Support, I am trying to load a PNG from a resource. The FindResourceHandle routine always returns hInst = 0. The code used to load the resource is as follows: CExtSkinBitmap _bmpTmp; HRSRC hRsrc = NULL; LPCTSTR strPngResourceSection = _T("PNG"); HINSTANCE hInst = g_ResourceManager->FindResourceHandle( strPngResourceSection, IDB_pngJogJointSpace, NULL, &hRsrc ); ASSERT( hInst ); ASSERT( hRsrc ); VERIFY( _bmpTmp.LoadPNG_Resource( hInst, hRsrc ) ); In the resource.h file there is: #define IDB_pngJogJointSpace 411 In the Ziggy.rc file there is: IDB_pngJogJointSpace PNG "res\\JointSpace.png" I have also included the PNG file. Please tell me what I’m doing incorrectly. Thanks, Gil Ross
|
|
Technical Support
|
Jul 30, 2008 - 4:03 AM
|
The PNG file is loaded successfully in the following simplest possible test project:
http://www.prof-uis.com/download/forums/TestPng.zip
It uses your PNG loading source code. So, the problem is hidden somewhere else. We suspect your project configures the resource manager in some special way so it cannot find the appropriate PNG resource
|
|
Jeremy Richards
|
Jul 29, 2008 - 11:19 AM
|
Well, I recently tried doing this in a legacy Prof-UIS app. Here is what I came up with: bool CPngBitmap::LoadFromResource(UINT resID) {
Empty();
LPCTSTR strPngImageResourceID = MAKEINTRESOURCE( resID );
LPCTSTR strPngResourceSection = _T("PNG");
HINSTANCE hInst = ::AfxFindResourceHandle( strPngImageResourceID, strPngResourceSection );
ASSERT( hInst );
HRSRC hRsrc = ::FindResource( hInst, strPngImageResourceID, strPngResourceSection );
ASSERT( hRsrc );
bool retVal = LoadPNG_Resource( hInst, hRsrc );
ASSERT(retVal);
return retVal;
} The only real difference that I can see is that I call ::AfxFindResourceHandle instead of using g_ResourceManager. It seems clear we both copied the example code provided. Mine works fine. My resource is directly in the .exe itself, and not loaded by any DLLs.
|
|