+ return m_dll.IsLoaded() ? m_dll.GetSymbol(name) : NULL;
+ }
+
+ void Unload()
+ {
+ if ( m_dll.IsLoaded() )
+ {
+ m_dll.Unload();
+ }
+ }
+
+private:
+ wxDynamicLibrary m_dll;
+ const wxChar *m_dllName;
+};
+
+static wxOnceOnlyDLLLoader wxMSIMG32DLL(wxT("msimg32"));
+
+// we must ensure that DLLs are unloaded before the static objects cleanup time
+// because we may hit the notorious DllMain() dead lock in this case if wx is
+// used as a DLL (attempting to unload another DLL from inside DllMain() hangs
+// under Windows because it tries to reacquire the same lock)
+class wxGDIDLLsCleanupModule : public wxModule
+{
+public:
+ virtual bool OnInit() { return true; }
+ virtual void OnExit() { wxMSIMG32DLL.Unload(); }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxGDIDLLsCleanupModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIDLLsCleanupModule, wxModule)
+
+namespace
+{
+
+#if wxUSE_DC_TRANSFORM_MATRIX
+
+// Class used to dynamically load world transform related API functions.
+class GdiWorldTransformFuncs
+{
+public:
+ static bool IsOk()
+ {
+ if ( !ms_worldTransformSymbolsLoaded )
+ LoadWorldTransformSymbols();
+
+ return ms_pfnSetGraphicsMode &&
+ ms_pfnSetWorldTransform &&
+ ms_pfnGetWorldTransform &&
+ ms_pfnModifyWorldTransform;
+ }
+
+ typedef int (WINAPI *SetGraphicsMode_t)(HDC, int);
+ static SetGraphicsMode_t SetGraphicsMode()
+ {
+ if ( !ms_worldTransformSymbolsLoaded )
+ LoadWorldTransformSymbols();
+
+ return ms_pfnSetGraphicsMode;
+ }
+
+ typedef BOOL (WINAPI *SetWorldTransform_t)(HDC, const XFORM *);
+ static SetWorldTransform_t SetWorldTransform()
+ {
+ if ( !ms_worldTransformSymbolsLoaded )
+ LoadWorldTransformSymbols();
+
+ return ms_pfnSetWorldTransform;
+ }
+
+ typedef BOOL (WINAPI *GetWorldTransform_t)(HDC, LPXFORM);
+ static GetWorldTransform_t GetWorldTransform()
+ {
+ if ( !ms_worldTransformSymbolsLoaded )
+ LoadWorldTransformSymbols();
+
+ return ms_pfnGetWorldTransform;
+ }
+
+ typedef BOOL (WINAPI *ModifyWorldTransform_t)(HDC, const XFORM *, DWORD);
+ static ModifyWorldTransform_t ModifyWorldTransform()
+ {
+ if ( !ms_worldTransformSymbolsLoaded )
+ LoadWorldTransformSymbols();
+
+ return ms_pfnModifyWorldTransform;