added wxTextEntry::AutoCompleteFileNames() and implemented it for wxMSW
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ecaed0bcda
commit
59396417d3
@ -185,7 +185,7 @@ All (Unix):
|
||||
|
||||
All (GUI):
|
||||
|
||||
- Added wxTextCtrl::AutoComplete()
|
||||
- Added {wxTextCtrl,wxComboBox}::AutoComplete() and AutoCompleteFileNames()
|
||||
- Added wxH[V]ScrolledWindow (Brad Anderson, Bryan Petty).
|
||||
- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron).
|
||||
- Added support for drop down toolbar buttons (Tim Kosse).
|
||||
|
@ -340,6 +340,37 @@ nothing under the other platforms.
|
||||
|
||||
\newsince{2.9.0}
|
||||
|
||||
\wxheading{Return value}
|
||||
|
||||
\true if the auto-completion was enabled or \false if the operation failed,
|
||||
typically because auto-completion is not supported by the current platform.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{AutoCompleteFileNames}{wxtextctrlautocompletefilenames}
|
||||
|
||||
|
||||
\membersection{wxTextCtrl::AutoCompleteFileNames}\label{wxtextctrlautocompletefilenames}
|
||||
|
||||
\func{bool}{AutoCompleteFileNames}{\void}
|
||||
|
||||
Call this function to enable auto-completion of the text typed in a single-line
|
||||
text control using all valid file system paths.
|
||||
|
||||
Notice that currently this function is only implemented in wxGTK2 port and does
|
||||
nothing under the other platforms.
|
||||
|
||||
\newsince{2.9.0}
|
||||
|
||||
\wxheading{Return value}
|
||||
|
||||
\true if the auto-completion was enabled or \false if the operation failed,
|
||||
typically because auto-completion is not supported by the current platform.
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{AutoComplete}{wxtextctrlautocomplete}
|
||||
|
||||
|
||||
\membersection{wxTextCtrl::CanCopy}\label{wxtextctrlcancopy}
|
||||
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
{ DoSetSelection(from, to); }
|
||||
virtual void GetSelection(long *from, long *to) const;
|
||||
|
||||
virtual bool AutoCompleteFileNames();
|
||||
|
||||
virtual bool IsEditable() const;
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
|
@ -98,7 +98,20 @@ public:
|
||||
// auto-completion
|
||||
// ---------------
|
||||
|
||||
virtual void AutoComplete(const wxArrayString& WXUNUSED(choices)) { }
|
||||
// these functions allow to auto-complete the text already entered into the
|
||||
// control using either the given fixed list of strings, the paths from the
|
||||
// file system or, in the future, an arbitrary user-defined completer
|
||||
//
|
||||
// they all return true if completion was enabled or false on error (most
|
||||
// commonly meaning that this functionality is not available under the
|
||||
// current platform)
|
||||
|
||||
virtual bool AutoComplete(const wxArrayString& WXUNUSED(choices))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool AutoCompleteFileNames() { return false; }
|
||||
|
||||
|
||||
// status
|
||||
|
@ -30,9 +30,14 @@
|
||||
#if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
|
||||
|
||||
#include "wx/textentry.h"
|
||||
#include "wx/dynlib.h"
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
#ifndef SHACF_FILESYS_ONLY
|
||||
#define SHACF_FILESYS_ONLY 0x00000010
|
||||
#endif
|
||||
|
||||
#define GetEditHwnd() ((HWND)(GetEditHWND()))
|
||||
|
||||
// ============================================================================
|
||||
@ -135,6 +140,39 @@ void wxTextEntry::GetSelection(long *from, long *to) const
|
||||
*to = dwEnd;
|
||||
}
|
||||
|
||||
bool wxTextEntry::AutoCompleteFileNames()
|
||||
{
|
||||
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) )
|
||||
{
|
||||
s_pfnSHAutoComplete = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDL_INIT_FUNC(s_pfn, SHAutoComplete, s_dllShlwapi);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !s_pfnSHAutoComplete )
|
||||
return false;
|
||||
|
||||
HRESULT hr = (*s_pfnSHAutoComplete)(GetEditHwnd(), SHACF_FILESYS_ONLY);
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wxLogApiError(_T("SHAutoComplete()"), hr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTextEntry::IsEditable() const
|
||||
{
|
||||
return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE) & ES_READONLY);
|
||||
|
Loading…
Reference in New Issue
Block a user