From 615b932f724422f1419a9d03cc9c719510ca20ed Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Wed, 16 Sep 2015 00:06:43 +0200 Subject: [PATCH] Remove dynamic loading of SHAutoComplete. Available since Win2k. --- src/msw/textentry.cpp | 23 ++++------------------- src/msw/utilsgui.cpp | 38 ++++---------------------------------- 2 files changed, 8 insertions(+), 53 deletions(-) diff --git a/src/msw/textentry.cpp b/src/msw/textentry.cpp index 12fa0b4dfa..d352b42bd0 100644 --- a/src/msw/textentry.cpp +++ b/src/msw/textentry.cpp @@ -39,6 +39,9 @@ #include "wx/msw/uxtheme.h" #endif +#include "wx/msw/wrapwin.h" +#include + #define GetEditHwnd() ((HWND)(GetEditHWND())) // ---------------------------------------------------------------------------- @@ -775,24 +778,6 @@ void wxTextEntry::GetSelection(long *from, long *to) const bool wxTextEntry::DoAutoCompleteFileNames(int flags) { - typedef HRESULT (WINAPI *SHAutoComplete_t)(HWND, DWORD); - static SHAutoComplete_t s_pfnSHAutoComplete = (SHAutoComplete_t)-1; - static wxDynamicLibrary s_dllShlwapi; - if ( s_pfnSHAutoComplete == (SHAutoComplete_t)-1 ) - { - if ( !s_dllShlwapi.Load(wxT("shlwapi.dll"), wxDL_VERBATIM | wxDL_QUIET) ) - { - s_pfnSHAutoComplete = NULL; - } - else - { - wxDL_INIT_FUNC(s_pfn, SHAutoComplete, s_dllShlwapi); - } - } - - if ( !s_pfnSHAutoComplete ) - return false; - DWORD dwFlags = 0; if ( flags & wxFILE ) dwFlags |= SHACF_FILESYS_ONLY; @@ -804,7 +789,7 @@ bool wxTextEntry::DoAutoCompleteFileNames(int flags) return false; } - HRESULT hr = (*s_pfnSHAutoComplete)(GetEditHwnd(), dwFlags); + HRESULT hr = ::SHAutoComplete(GetEditHwnd(), dwFlags); if ( FAILED(hr) ) { wxLogApiError(wxT("SHAutoComplete()"), hr); diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index c3afab2db3..fec084786c 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -29,10 +29,11 @@ #include "wx/utils.h" #endif //WX_PRECOMP -#include "wx/dynlib.h" - #include "wx/msw/private.h" // includes +#include "wx/msw/wrapwin.h" +#include + // ============================================================================ // implementation // ============================================================================ @@ -264,34 +265,7 @@ void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2) 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(wxT("shlwapi.dll")); - if ( dll.IsLoaded() ) - { - s_pfnSHAutoComplete = - (SHAutoComplete_t)dll.GetSymbol(wxT("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 */); + HRESULT hr = ::SHAutoComplete(hwnd, 0x10 /* SHACF_FILESYS_ONLY */); if ( FAILED(hr) ) { wxLogApiError(wxT("SHAutoComplete"), hr); @@ -299,8 +273,4 @@ extern bool wxEnableFileNameAutoComplete(HWND hwnd) } return true; -#else - wxUnusedVar(hwnd); - return false; -#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS }