X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0847dca672bc870e3462bc54b00a39a96c70d3ae..dd9f8b6bb6935360a8271dc3e8749fb026b601a8:/src/msw/textentry.cpp diff --git a/src/msw/textentry.cpp b/src/msw/textentry.cpp index e868fea193..b763b5de8e 100644 --- a/src/msw/textentry.cpp +++ b/src/msw/textentry.cpp @@ -24,6 +24,7 @@ #endif #ifndef WX_PRECOMP + #include "wx/arrstr.h" #include "wx/string.h" #endif // WX_PRECOMP @@ -34,21 +35,35 @@ #include "wx/msw/private.h" -#ifndef SHACF_FILESYS_ONLY - #define SHACF_FILESYS_ONLY 0x00000010 -#endif - #define GetEditHwnd() ((HWND)(GetEditHWND())) // ---------------------------------------------------------------------------- // wxIEnumString implements IEnumString interface // ---------------------------------------------------------------------------- -#if wxUSE_OLE +// standard VC6 SDK (WINVER == 0x0400) does not know about IAutoComplete +#if wxUSE_OLE && (WINVER >= 0x0500) + #define HAS_AUTOCOMPLETE +#endif + +#ifdef HAS_AUTOCOMPLETE #include "wx/msw/ole/oleutils.h" #include +#if defined(__MINGW32__) || defined (__WATCOMC__) + // needed for IID_IAutoComplete, IID_IAutoComplete2 and ACO_AUTOSUGGEST + #include +#endif + +#ifndef ACO_UPDOWNKEYDROPSLIST + #define ACO_UPDOWNKEYDROPSLIST 0x20 +#endif + +#ifndef SHACF_FILESYS_ONLY + #define SHACF_FILESYS_ONLY 0x00000010 +#endif + DEFINE_GUID(CLSID_AutoComplete, 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62); @@ -80,7 +95,7 @@ public: if ( m_index == count ) return S_FALSE; - const wxWX2WCbuf wcbuf(m_strings[m_index].wc_str()); + const wxWX2WCbuf wcbuf = m_strings[m_index].wc_str(); const size_t size = (wcslen(wcbuf) + 1)*sizeof(wchar_t); void *olestr = CoTaskMemAlloc(size); if ( !olestr ) @@ -130,6 +145,13 @@ public: } private: + // dtor doesn't have to be virtual as we're only ever deleted from our own + // Release() and are not meant to be derived form anyhow, but making it + // virtual silences gcc warnings; making it private makes it impossible to + // (mistakenly) delete us directly instead of calling Release() + virtual ~wxIEnumString() { } + + const wxArrayString m_strings; unsigned m_index; @@ -143,7 +165,7 @@ END_IID_TABLE; IMPLEMENT_IUNKNOWN_METHODS(wxIEnumString) -#endif // wxUSE_OLE +#endif // HAS_AUTOCOMPLETE // ============================================================================ // wxTextEntry implementation @@ -265,18 +287,15 @@ void wxTextEntry::GetSelection(long *from, long *to) const // auto-completion // ---------------------------------------------------------------------------- -#if wxUSE_OLE - bool wxTextEntry::AutoCompleteFileNames() { +#ifdef HAS_AUTOCOMPLETE 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 ) { - wxLogNull noLog; - - if ( !s_dllShlwapi.Load(_T("shlwapi.dll"), wxDL_VERBATIM) ) + if ( !s_dllShlwapi.Load(_T("shlwapi.dll"), wxDL_VERBATIM | wxDL_QUIET) ) { s_pfnSHAutoComplete = NULL; } @@ -296,12 +315,15 @@ bool wxTextEntry::AutoCompleteFileNames() return false; } - return true; +#else // !HAS_AUTOCOMPLETE + return false; +#endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE } bool wxTextEntry::AutoComplete(const wxArrayString& choices) { +#ifdef HAS_AUTOCOMPLETE // create an object exposing IAutoComplete interface (don't go for // IAutoComplete2 immediately as, presumably, it might be not available on // older systems as otherwise why do we have both -- although in practice I @@ -349,11 +371,13 @@ bool wxTextEntry::AutoComplete(const wxArrayString& choices) // do it immediately, presumably the edit control itself keeps a reference // to the auto completer object pAutoComplete->Release(); - return true; -} +#else // !HAS_AUTOCOMPLETE + wxUnusedVar(choices); -#endif // wxUSE_OLE + return false; +#endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE +} // ---------------------------------------------------------------------------- // editable state