]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utilsgui.cpp
Added URL support to attribute objects and to wxRichTextCtrl,
[wxWidgets.git] / src / msw / utilsgui.cpp
index 7926bdb3307ca5410804b6aba71e7100a25478bf..d1acea6ad5e2d32c31e485edd7d6bc7534810e4d 100644 (file)
@@ -30,6 +30,8 @@
     #include "wx/utils.h"
 #endif //WX_PRECOMP
 
+#include "wx/dynlib.h"
+
 #include "wx/msw/private.h"     // includes <windows.h>
 
 // ============================================================================
@@ -452,3 +454,50 @@ void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2)
 }
 
 
+// ----------------------------------------------------------------------------
+// Shell API wrappers
+// ----------------------------------------------------------------------------
+
+extern bool wxEnableFileNameAutoComplete(HWND hwnd)
+{
+#if wxUSE_DYNLIB_CLASS
+    typedef HRESULT (WINAPI *SHAutoComplete_t)(HWND, DWORD);
+
+    static SHAutoComplete_t s_pfnSHAutoComplete = NULL;
+    static bool s_initialized = false;
+
+    if ( !s_initialized )
+    {
+        s_initialized = true;
+
+        wxLogNull nolog;
+        wxDynamicLibrary dll(_T("shlwapi.dll"));
+        if ( dll.IsLoaded() )
+        {
+            s_pfnSHAutoComplete =
+                (SHAutoComplete_t)dll.GetSymbol(_T("SHAutoComplete"));
+            if ( s_pfnSHAutoComplete )
+            {
+                // won't be unloaded until the process termination, no big deal
+                dll.Detach();
+            }
+        }
+    }
+
+    if ( !s_pfnSHAutoComplete )
+        return false;
+
+    HRESULT hr = s_pfnSHAutoComplete(hwnd, 0x10 /* SHACF_FILESYS_ONLY */);
+    if ( FAILED(hr) )
+    {
+        wxLogApiError(_T("SHAutoComplete"), hr);
+        return false;
+    }
+
+    return true;
+#else
+    wxUnusedVar(hwnd);
+    return false;
+#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
+}
+