From: Václav Slavík Date: Mon, 26 Apr 2010 20:51:02 +0000 (+0000) Subject: Add instance argument to wxLoadUserResource(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/18923e360c44744dcf7e4f2be7fbae3c447a939a 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 --- diff --git a/include/wx/utils.h b/include/wx/utils.h index 18fb415640..533e8a489e 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -737,7 +737,8 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded(); wxLoadUserResource(const void **outData, size_t *outLen, 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 // data, remember to delete[] the buffer. And avoid using it entirely if @@ -747,7 +748,8 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded(); WXDLLIMPEXP_BASE char* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr, - int* pLen = NULL); + int* pLen = NULL, + WXHINSTANCE module = 0); #endif // MSW #endif diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 2958f75788..c7b64cc6dd 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1085,17 +1085,18 @@ bool wxLoadUserResource(const void **outData, size_t *outLen, const wxString& resourceName, - const wxString& resourceType) + const wxString& resourceType, + WXHINSTANCE instance) { wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" ); - HRSRC hResource = ::FindResource(wxGetInstance(), + HRSRC hResource = ::FindResource(instance, resourceName.wx_str(), resourceType.wx_str()); if ( !hResource ) return false; - HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource); + HGLOBAL hData = ::LoadResource(instance, hResource); if ( !hData ) { wxLogSysError(_("Failed to load resource \"%s\"."), resourceName); @@ -1109,7 +1110,7 @@ wxLoadUserResource(const void **outData, return false; } - *outLen = ::SizeofResource(wxGetInstance(), hResource); + *outLen = ::SizeofResource(instance, hResource); // Notice that we do not need to call neither UnlockResource() (which is // obsolete in Win32) nor GlobalFree() (resources are freed on process @@ -1121,11 +1122,12 @@ wxLoadUserResource(const void **outData, char * wxLoadUserResource(const wxString& resourceName, const wxString& resourceType, - int* pLen) + int* pLen, + WXHINSTANCE instance) { const void *data; size_t len; - if ( !wxLoadUserResource(&data, &len, resourceName, resourceType) ) + if ( !wxLoadUserResource(&data, &len, resourceName, resourceType, instance) ) return NULL; char *s = new char[len + 1];