]> git.saurik.com Git - wxWidgets.git/commitdiff
don't load comctl32.dll, just get the handle of the already loaded instance of it...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Nov 2008 16:45:45 +0000 (16:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Nov 2008 16:45:45 +0000 (16:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56863 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dynlib.h
src/msw/app.cpp
src/msw/datecontrols.cpp
src/msw/dlmsw.cpp
src/msw/window.cpp

index a6a45f74c11acfef531fd96b2fd376772c53d5af..3d31beeb80aeaae7e6daa6143b5ae00b04a8410c 100644 (file)
@@ -73,11 +73,19 @@ enum wxDLFlags
     wxDL_VERBATIM   = 0x00000008,   // attempt to load the supplied library
                                     // name without appending the usual dll
                                     // filename extension.
+
+    // this flag is obsolete, don't use
     wxDL_NOSHARE    = 0x00000010,   // load new DLL, don't reuse already loaded
                                     // (only for wxPluginManager)
 
     wxDL_QUIET      = 0x00000020,   // don't log an error if failed to load
 
+    // this flag is dangerous, for internal use of wxMSW only, don't use
+    wxDL_GET_LOADED = 0x00000040,   // Win32 only: return handle of already
+                                    // loaded DLL or NULL otherwise; Unload()
+                                    // should not be called so don't forget to
+                                    // Detach() if you use this function
+
     wxDL_DEFAULT    = wxDL_NOW      // default flags correspond to Win32
 };
 
index ccac439ee78e6394502d7cee7b65fc0a41d8e3d4..fccf2634094c2ba08d5e1004f5509fcf79960412 100644 (file)
@@ -966,8 +966,14 @@ int wxApp::GetComCtl32Version()
         // we're prepared to handle the errors
         wxLogNull noLog;
 
-        // the DLL should really be available
-        wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
+        // we don't want to load comctl32.dll, it should be already loaded but,
+        // depending on the OS version and the presence of the manifest, it can
+        // be either v5 or v6 and instead of trying to guess it just get the
+        // handle of the already loaded version
+        wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+                                     wxDL_VERBATIM |
+                                     wxDL_QUIET |
+                                     wxDL_GET_LOADED);
         if ( !dllComCtl32.IsLoaded() )
         {
             s_verComCtl32 = 0;
@@ -1005,6 +1011,9 @@ int wxApp::GetComCtl32Version()
                 }
             }
         }
+
+        // we shouldn't unload it here as we didn't really load it above
+        dllComCtl32.Detach();
     }
 
     return s_verComCtl32;
index 3af793ec521228eb8d855ec0b20033329dbf7870..6960f09aeea870488d59f372c2e64700b5349016 100644 (file)
@@ -67,10 +67,17 @@ bool wxMSWDateControls::CheckInitialization()
         icex.dwSize = sizeof(icex);
         icex.dwICC = ICC_DATE_CLASSES;
 
-        wxDynamicLibrary dllComCtl32(_T("comctl32.dll") , wxDL_VERBATIM);
+        // see comment in wxApp::GetComCtl32Version() explaining the
+        // use of wxDL_GET_LOADED
+        wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+                                     wxDL_VERBATIM |
+                                     wxDL_QUIET |
+                                     wxDL_GET_LOADED);
 
         if ( dllComCtl32.IsLoaded() )
         {
+            wxLogNull noLog;
+
             typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
             wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
 
index 0b4d76de179e5f59ed52277e0eecc35495e71bf5..280dab0e281bdf5976cff8e0702f20b161285ff8 100644 (file)
@@ -282,9 +282,11 @@ wxDllType wxDynamicLibrary::GetProgramHandle()
 
 /* static */
 wxDllType
-wxDynamicLibrary::RawLoad(const wxString& libname, int WXUNUSED(flags))
+wxDynamicLibrary::RawLoad(const wxString& libname, int flags)
 {
-    return ::LoadLibrary(libname.t_str());
+    return flags & wxDL_GET_LOADED
+            ? ::GetModuleHandle(libname.t_str())
+            : ::LoadLibrary(libname.t_str());
 }
 
 /* static */
index ea9a66c3c0db2be3e382d3cd8b6274140c277008..b5004af9d21088066ef4aa0302bb9c5c39544421 100644 (file)
@@ -5306,20 +5306,23 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags)
             static bool s_initDone = false;
             if ( !s_initDone )
             {
-                wxLogNull noLog;
-
-                wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
+                // see comment in wxApp::GetComCtl32Version() explaining the
+                // use of wxDL_GET_LOADED
+                wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+                                             wxDL_VERBATIM |
+                                             wxDL_QUIET |
+                                             wxDL_GET_LOADED);
                 if ( dllComCtl32.IsLoaded() )
                 {
                     s_pfn_TrackMouseEvent = (_TrackMouseEvent_t)
-                        dllComCtl32.GetSymbol(_T("_TrackMouseEvent"));
+                        dllComCtl32.RawGetSymbol(_T("_TrackMouseEvent"));
                 }
 
                 s_initDone = true;
 
-                // notice that it's ok to unload comctl32.dll here as it won't
-                // be really unloaded, being still in use because we link to it
-                // statically too
+                // we shouldn't unload comctl32.dll here as we didn't really
+                // load it above
+                dllComCtl32.Detach();
             }
 
             if ( s_pfn_TrackMouseEvent )