Add instance argument to wxLoadUserResource().
This makes it possible to load resources from other modules than the main executable. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64152 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -737,7 +737,8 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
|
|||||||
wxLoadUserResource(const void **outData,
|
wxLoadUserResource(const void **outData,
|
||||||
size_t *outLen,
|
size_t *outLen,
|
||||||
const wxString& resourceName,
|
const wxString& resourceName,
|
||||||
const wxString& resourceType = wxUserResourceStr);
|
const wxString& resourceType = wxUserResourceStr,
|
||||||
|
WXHINSTANCE module = 0);
|
||||||
|
|
||||||
// This function allocates a new buffer and makes a copy of the resource
|
// This function allocates a new buffer and makes a copy of the resource
|
||||||
// data, remember to delete[] the buffer. And avoid using it entirely if
|
// data, remember to delete[] the buffer. And avoid using it entirely if
|
||||||
@@ -747,7 +748,8 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
|
|||||||
WXDLLIMPEXP_BASE char*
|
WXDLLIMPEXP_BASE char*
|
||||||
wxLoadUserResource(const wxString& resourceName,
|
wxLoadUserResource(const wxString& resourceName,
|
||||||
const wxString& resourceType = wxUserResourceStr,
|
const wxString& resourceType = wxUserResourceStr,
|
||||||
int* pLen = NULL);
|
int* pLen = NULL,
|
||||||
|
WXHINSTANCE module = 0);
|
||||||
#endif // MSW
|
#endif // MSW
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1085,17 +1085,18 @@ bool
|
|||||||
wxLoadUserResource(const void **outData,
|
wxLoadUserResource(const void **outData,
|
||||||
size_t *outLen,
|
size_t *outLen,
|
||||||
const wxString& resourceName,
|
const wxString& resourceName,
|
||||||
const wxString& resourceType)
|
const wxString& resourceType,
|
||||||
|
WXHINSTANCE instance)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" );
|
wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" );
|
||||||
|
|
||||||
HRSRC hResource = ::FindResource(wxGetInstance(),
|
HRSRC hResource = ::FindResource(instance,
|
||||||
resourceName.wx_str(),
|
resourceName.wx_str(),
|
||||||
resourceType.wx_str());
|
resourceType.wx_str());
|
||||||
if ( !hResource )
|
if ( !hResource )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
|
HGLOBAL hData = ::LoadResource(instance, hResource);
|
||||||
if ( !hData )
|
if ( !hData )
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Failed to load resource \"%s\"."), resourceName);
|
wxLogSysError(_("Failed to load resource \"%s\"."), resourceName);
|
||||||
@@ -1109,7 +1110,7 @@ wxLoadUserResource(const void **outData,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*outLen = ::SizeofResource(wxGetInstance(), hResource);
|
*outLen = ::SizeofResource(instance, hResource);
|
||||||
|
|
||||||
// Notice that we do not need to call neither UnlockResource() (which is
|
// Notice that we do not need to call neither UnlockResource() (which is
|
||||||
// obsolete in Win32) nor GlobalFree() (resources are freed on process
|
// obsolete in Win32) nor GlobalFree() (resources are freed on process
|
||||||
@@ -1121,11 +1122,12 @@ wxLoadUserResource(const void **outData,
|
|||||||
char *
|
char *
|
||||||
wxLoadUserResource(const wxString& resourceName,
|
wxLoadUserResource(const wxString& resourceName,
|
||||||
const wxString& resourceType,
|
const wxString& resourceType,
|
||||||
int* pLen)
|
int* pLen,
|
||||||
|
WXHINSTANCE instance)
|
||||||
{
|
{
|
||||||
const void *data;
|
const void *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
if ( !wxLoadUserResource(&data, &len, resourceName, resourceType) )
|
if ( !wxLoadUserResource(&data, &len, resourceName, resourceType, instance) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char *s = new char[len + 1];
|
char *s = new char[len + 1];
|
||||||
|
Reference in New Issue
Block a user