]> git.saurik.com Git - wxWidgets.git/commitdiff
Add instance argument to wxLoadUserResource().
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 26 Apr 2010 20:51:02 +0000 (20:51 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 26 Apr 2010 20:51:02 +0000 (20:51 +0000)
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

include/wx/utils.h
src/msw/utils.cpp

index 18fb41564046e254b4ab0df9b53bdeb30f899fcb..533e8a489e9960fd672b9f471d9ad99178e20822 100644 (file)
@@ -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
index 2958f75788cecb009c0ac87bebec596c1325d224..c7b64cc6dd81af059679261be3e70f2c9a647417 100644 (file)
@@ -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];