|
|
|
|
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 18, 2008 - 7:47 PM
|
Dear Support, I have a PNG image I would like to use in a CExtButton class. I am having trouble loading the image. I have used the MS Visual Studio resource editor to import the PNG image. The loading code is below: // Load PNG from resources: CExtSkinBitmap _bmpTmp; LPCTSTR strPngImageResourceID = MAKEINTRESOURCE( IDB_pngJogCcw ); LPCTSTR strPngResourceSection = _T("PNG"); HINSTANCE hInst = ::AfxFindResourceHandle( strPngImageResourceID, strPngResourceSection ); ASSERT( hInst ); HRSRC hRsrc = g_ResourceManager->FindResourceHandle( hInst, strPngImageResourceID, strPngResourceSection ); ASSERT( hRsrc ); VERIFY( _bmpTmp.LoadPNG_Resource( hInst, hRsrc ) ); Resource file: ///////////////////////////////////////////////////////////////////////////// // // PNG // IDB_pngJogCcw PNG "res\\test_arrow_button.png" I get a compile error:
1>c:\source\studio 2008\plugins\ziggy\vrtabchildjointspace.cpp(99) : error C2664: ’CExtResourceManager::FindResourceHandle’ : cannot convert parameter 1 from ’HINSTANCE’ to ’__EXT_MFC_SAFE_LPCTSTR’);
From your documentation, once I load the png image I can then load it into a CExtButton object using the SetIcon routine. Is this true?
Thanks,
Gil
|
|
Technical Support
|
Jul 19, 2008 - 11:46 AM
|
You are invoking the CExtResourceManager::FindResourceHandle() method with incorrect parameters. Here is declaration of this method:HINSTANCE FindResourceHandle(
__EXT_MFC_SAFE_LPCTSTR strResourceType,
UINT nResourceName,
WORD * p_wLangIdOut = NULL,
HRSRC * p_hResourceOut = NULL
)
This is how you are invoking it:
HINSTANCE hInst = ::AfxFindResourceHandle( strPngImageResourceID, strPngResourceSection );
ASSERT( hInst );
hRsrc = g_ResourceManager->FindResourceHandle( hInst, strPngImageResourceID, strPngResourceSection );
This is how it should be invoked:
HRSRC hRsrc = NULL;
HINSTANCE hInst = g_ResourceManager->FindResourceHandle( strPngResourceSection, IDB_pngJogCcw, NULL, &hRsrc );
ASSERT( hInst != NULL );
ASSERT( hRsrc != NULL);
So, invocation of AfxFindResourceHandle() API is not needed at all. By default, the the CExtResourceManager::FindResourceHandle() method does the same as the AfxFindResourceHandle() API. But it’s possible to configure the Prof-UIS resource manager for searching resources in several DLL/EXE modules before starting default search algorithm similar to that implemented in the AfxFindResourceHandle() API. Please note, you can insert resource copies for several languages, including PNG resources, and then make your application searching resources of some preferred by user language. This can be done using the CExtResourceManager::FindResourceHandleEx() method which allows to specify desired language identifier for searching.
|
|