1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/textentry.cpp
3 // Purpose: wxTextEntry implementation for wxMSW
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
26 #include "wx/arrstr.h"
27 #include "wx/string.h"
30 #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
32 #include "wx/textentry.h"
33 #include "wx/textcompleter.h"
34 #include "wx/dynlib.h"
36 #include "wx/msw/private.h"
39 #include "wx/msw/uxtheme.h"
42 #define GetEditHwnd() ((HWND)(GetEditHWND()))
44 // ----------------------------------------------------------------------------
45 // Classes used by auto-completion implementation.
46 // ----------------------------------------------------------------------------
48 // standard VC6 SDK (WINVER == 0x0400) does not know about IAutoComplete
49 #if wxUSE_OLE && (WINVER >= 0x0500)
50 #define HAS_AUTOCOMPLETE
53 #ifdef HAS_AUTOCOMPLETE
55 #include "wx/msw/ole/oleutils.h"
58 #if defined(__MINGW32__) || defined (__WATCOMC__) || defined(__CYGWIN__)
59 // needed for IID_IAutoComplete, IID_IAutoComplete2 and ACO_AUTOSUGGEST
62 #ifndef ACO_AUTOAPPEND
63 #define ACO_AUTOAPPEND 0x02
67 #ifndef ACO_UPDOWNKEYDROPSLIST
68 #define ACO_UPDOWNKEYDROPSLIST 0x20
71 #ifndef SHACF_FILESYS_ONLY
72 #define SHACF_FILESYS_ONLY 0x00000010
75 #ifndef SHACF_FILESYS_DIRS
76 #define SHACF_FILESYS_DIRS 0x00000020
79 // This must be the last header included to only affect the DEFINE_GUID()
80 // occurrences below but not any GUIDs declared in the standard files included
87 // Normally this interface and its IID are defined in shobjidl.h header file
88 // included in the platform SDK but MinGW and Cygwin don't have it so redefine
89 // the interface ourselves and, as long as we do it all, do it for all
90 // compilers to ensure we have the same behaviour for all of them and to avoid
91 // the need to check for concrete compilers and maybe even their versions.
92 class IAutoCompleteDropDown
: public IUnknown
95 virtual HRESULT wxSTDCALL
GetDropDownStatus(DWORD
*, LPWSTR
*) = 0;
96 virtual HRESULT wxSTDCALL
ResetEnumerator() = 0;
99 DEFINE_GUID(wxIID_IAutoCompleteDropDown
,
100 0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);
102 DEFINE_GUID(wxCLSID_AutoComplete
,
103 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62);
105 // Small helper class which can be used to ensure thread safety even when
106 // wxUSE_THREADS==0 (and hence wxCriticalSection does nothing).
110 CSLock(CRITICAL_SECTION
& cs
) : m_cs(&cs
)
112 ::EnterCriticalSection(m_cs
);
117 ::LeaveCriticalSection(m_cs
);
121 CRITICAL_SECTION
* const m_cs
;
123 wxDECLARE_NO_COPY_CLASS(CSLock
);
126 } // anonymity namespace
128 // Implementation of string enumerator used by wxTextAutoCompleteData. This
129 // class simply forwards to wxTextCompleter associated with it.
131 // Notice that Next() method of this class is called by IAutoComplete
132 // background thread and so we must care about thread safety here.
133 class wxIEnumString
: public IEnumString
141 void ChangeCompleter(wxTextCompleter
*completer
)
143 // Indicate to Next() that it should bail out as soon as possible.
145 CSLock
lock(m_csRestart
);
150 // Now try to enter this critical section to ensure that Next() doesn't
151 // use the old pointer any more before changing it (this is vital as
152 // the old pointer will be destroyed after we return).
153 CSLock
lock(m_csCompleter
);
155 m_completer
= completer
;
158 void UpdatePrefix(const wxString
& prefix
)
160 CSLock
lock(m_csRestart
);
162 // We simply store the prefix here and will really update during the
163 // next call to our Next() method as we want to call Start() from the
164 // worker thread to prevent the main UI thread from blocking while the
165 // completions are generated.
170 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG celt
,
174 if ( !rgelt
|| (!pceltFetched
&& celt
> 1) )
177 ULONG pceltFetchedDummy
;
179 pceltFetched
= &pceltFetchedDummy
;
183 CSLock
lock(m_csCompleter
);
185 if ( !RestartIfNeeded() )
190 // Stop iterating if we need to update completions anyhow.
194 const wxString s
= m_completer
->GetNext();
198 const wxWX2WCbuf wcbuf
= s
.wc_str();
199 const size_t size
= (wcslen(wcbuf
) + 1)*sizeof(wchar_t);
200 void *olestr
= CoTaskMemAlloc(size
);
202 return E_OUTOFMEMORY
;
204 memcpy(olestr
, wcbuf
, size
);
206 *rgelt
++ = static_cast<LPOLESTR
>(olestr
);
214 virtual HRESULT STDMETHODCALLTYPE
Skip(ULONG celt
)
219 CSLock
lock(m_csCompleter
);
221 if ( !RestartIfNeeded() )
229 if ( m_completer
->GetNext().empty() )
236 virtual HRESULT STDMETHODCALLTYPE
Reset()
238 CSLock
lock(m_csRestart
);
245 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumString
**ppEnum
)
250 CSLock
lock(m_csCompleter
);
252 wxIEnumString
* const e
= new wxIEnumString
;
255 e
->ChangeCompleter(m_completer
);
262 DECLARE_IUNKNOWN_METHODS
;
265 // dtor doesn't have to be virtual as we're only ever deleted from our own
266 // Release() and are not meant to be derived form anyhow, but making it
267 // virtual silences gcc warnings; making it private makes it impossible to
268 // (mistakenly) delete us directly instead of calling Release()
269 virtual ~wxIEnumString()
271 ::DeleteCriticalSection(&m_csRestart
);
272 ::DeleteCriticalSection(&m_csCompleter
);
275 // Common part of all ctors.
278 ::InitializeCriticalSection(&m_csCompleter
);
279 ::InitializeCriticalSection(&m_csRestart
);
285 // Restart completions generation if needed. Should be only called from
286 // inside m_csCompleter.
288 // If false is returned, it means that there are no completions and that
289 // wxTextCompleter::GetNext() shouldn't be called at all.
290 bool RestartIfNeeded()
298 CSLock
lock(m_csRestart
);
304 } // Release m_csRestart before calling Start() to avoid blocking
305 // the main thread in UpdatePrefix() during its execution.
310 rc
= m_completer
->Start(prefix
);
317 // Critical section protecting m_completer itself. It must be entered when
318 // using the pointer to ensure that we don't continue using a dangling one
319 // after it is destroyed.
320 CRITICAL_SECTION m_csCompleter
;
322 // The completer we delegate to for the completions generation. It is never
323 // NULL after the initial ChangeCompleter() call.
324 wxTextCompleter
*m_completer
;
327 // Critical section m_prefix and m_restart. It should be only entered for
328 // short periods of time, i.e. we shouldn't call any wxTextCompleter
329 // methods from inside, to prevent the main thread from blocking on it in
331 CRITICAL_SECTION m_csRestart
;
333 // If m_restart is true, we need to call wxTextCompleter::Start() with the
334 // given prefix to restart generating the completions.
337 // Notice that we use LONG and not bool here to ensure that reading this
338 // value is atomic (32 bit reads are atomic operations under all Windows
339 // versions but reading bool isn't necessarily).
343 wxDECLARE_NO_COPY_CLASS(wxIEnumString
);
346 BEGIN_IID_TABLE(wxIEnumString
)
351 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumString
)
354 // This class gathers the all auto-complete-related stuff we use. It is
355 // allocated on demand by wxTextEntry when AutoComplete() is called.
356 class wxTextAutoCompleteData wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
359 // The constructor associates us with the given text entry.
360 wxTextAutoCompleteData(wxTextEntry
*entry
)
362 m_win(entry
->GetEditableWindow())
364 m_autoComplete
= NULL
;
365 m_autoCompleteDropDown
= NULL
;
366 m_enumStrings
= NULL
;
368 m_fixedCompleter
= NULL
;
369 m_customCompleter
= NULL
;
371 m_connectedCharEvent
= false;
373 // Create an object exposing IAutoComplete interface which we'll later
374 // use to get IAutoComplete2 as the latter can't be created directly,
376 HRESULT hr
= CoCreateInstance
378 wxCLSID_AutoComplete
,
380 CLSCTX_INPROC_SERVER
,
382 reinterpret_cast<void **>(&m_autoComplete
)
386 wxLogApiError(wxT("CoCreateInstance(CLSID_AutoComplete)"), hr
);
390 // Create a string enumerator and initialize the completer with it.
391 m_enumStrings
= new wxIEnumString
;
392 m_enumStrings
->AddRef();
393 hr
= m_autoComplete
->Init(m_entry
->GetEditHWND(), m_enumStrings
,
397 wxLogApiError(wxT("IAutoComplete::Init"), hr
);
399 m_enumStrings
->Release();
400 m_enumStrings
= NULL
;
405 // As explained in DoRefresh(), we need to call IAutoCompleteDropDown::
406 // ResetEnumerator() if we want to be able to change the completions on
407 // the fly. In principle we could live without it, i.e. return true
408 // from IsOk() even if this QueryInterface() fails, but it doesn't look
409 // like this is ever going to have in practice anyhow as the shell-
410 // provided IAutoComplete always implements IAutoCompleteDropDown too.
411 hr
= m_autoComplete
->QueryInterface
413 wxIID_IAutoCompleteDropDown
,
414 reinterpret_cast<void **>(&m_autoCompleteDropDown
)
418 wxLogApiError(wxT("IAutoComplete::QI(IAutoCompleteDropDown)"), hr
);
422 // Finally set the completion options using IAutoComplete2.
423 IAutoComplete2
*pAutoComplete2
= NULL
;
424 hr
= m_autoComplete
->QueryInterface
427 reinterpret_cast<void **>(&pAutoComplete2
)
431 pAutoComplete2
->SetOptions(ACO_AUTOSUGGEST
|
433 ACO_UPDOWNKEYDROPSLIST
);
434 pAutoComplete2
->Release();
438 ~wxTextAutoCompleteData()
440 delete m_customCompleter
;
441 delete m_fixedCompleter
;
444 m_enumStrings
->Release();
445 if ( m_autoCompleteDropDown
)
446 m_autoCompleteDropDown
->Release();
447 if ( m_autoComplete
)
448 m_autoComplete
->Release();
451 // Must be called after creating this object to verify if initializing it
455 return m_autoComplete
&& m_autoCompleteDropDown
&& m_enumStrings
;
458 void ChangeStrings(const wxArrayString
& strings
)
460 if ( !m_fixedCompleter
)
461 m_fixedCompleter
= new wxTextCompleterFixed
;
463 m_fixedCompleter
->SetCompletions(strings
);
465 m_enumStrings
->ChangeCompleter(m_fixedCompleter
);
470 // Takes ownership of the pointer if it is non-NULL.
471 bool ChangeCustomCompleter(wxTextCompleter
*completer
)
473 // Ensure that the old completer is not used any more before deleting
475 m_enumStrings
->ChangeCompleter(completer
);
477 delete m_customCompleter
;
478 m_customCompleter
= completer
;
480 if ( m_customCompleter
)
482 // We postpone connecting to this event until we really need to do
483 // it (however we don't disconnect from it when we don't need it
484 // any more because we don't have wxUNBIND_OR_DISCONNECT_HACK...).
485 if ( !m_connectedCharEvent
)
487 m_connectedCharEvent
= true;
489 // Use the special wxEVT_AFTER_CHAR and not the usual
490 // wxEVT_CHAR here because we need to have the updated value of
491 // the text control in this handler in order to provide
492 // completions for the correct prefix and unfortunately we
493 // don't have any way to let DefWindowProc() run from our
494 // wxEVT_CHAR handler (as we must also let the other handlers
495 // defined at wx level run first).
497 // Notice that we can't use wxEVT_TEXT here
498 // neither as, due to our use of ACO_AUTOAPPEND, we get
499 // EN_CHANGE notifications from the control every time
500 // IAutoComplete auto-appends something to it.
501 wxBIND_OR_CONNECT_HACK(m_win
, wxEVT_AFTER_CHAR
,
503 wxTextAutoCompleteData::OnAfterChar
,
507 UpdateStringsFromCustomCompleter();
513 void DisableCompletion()
515 // We currently simply reset the list of possible strings as this seems
516 // to effectively disable auto-completion just fine. We could (and
517 // probably should) use IAutoComplete::Enable(FALSE) for this too but
518 // then we'd need to call Enable(TRUE) to turn it on back again later.
519 ChangeStrings(wxArrayString());
523 // Must be called after changing the values to be returned by wxIEnumString
524 // to really make the changes stick.
527 m_enumStrings
->Reset();
529 // This is completely and utterly not documented and in fact the
530 // current MSDN seems to try to discourage us from using it by saying
531 // that "there is no reason to use this method unless the drop-down
532 // list is currently visible" but actually we absolutely must call it
533 // to force the auto-completer (and not just its drop-down!) to refresh
534 // the list of completions which could have changed now. Without this
535 // call the new choices returned by GetCompletions() that hadn't been
536 // returned by it before are simply silently ignored.
537 m_autoCompleteDropDown
->ResetEnumerator();
540 // Update the strings returned by our string enumerator to correspond to
541 // the currently valid choices according to the custom completer.
542 void UpdateStringsFromCustomCompleter()
544 // As we use ACO_AUTOAPPEND, the selected part of the text is usually
545 // the one appended by us so don't consider it as part of the
546 // user-entered prefix.
548 m_entry
->GetSelection(&from
, &to
);
551 from
= m_entry
->GetLastPosition(); // Take all if no selection.
553 const wxString prefix
= m_entry
->GetRange(0, from
);
555 m_enumStrings
->UpdatePrefix(prefix
);
560 void OnAfterChar(wxKeyEvent
& event
)
562 // Notice that we must not refresh the completions when the user
563 // presses Backspace as this would result in adding back the just
564 // erased character(s) because of ACO_AUTOAPPEND option we use.
565 if ( m_customCompleter
&& event
.GetKeyCode() != WXK_BACK
)
566 UpdateStringsFromCustomCompleter();
572 // The text entry we're associated with.
573 wxTextEntry
* const m_entry
;
575 // The window of this text entry.
576 wxWindow
* const m_win
;
578 // The auto-completer object itself.
579 IAutoComplete
*m_autoComplete
;
581 // Its IAutoCompleteDropDown interface needed for ResetEnumerator() call.
582 IAutoCompleteDropDown
*m_autoCompleteDropDown
;
584 // Enumerator for strings currently used for auto-completion.
585 wxIEnumString
*m_enumStrings
;
587 // Fixed string completer or NULL if none.
588 wxTextCompleterFixed
*m_fixedCompleter
;
590 // Custom completer or NULL if none.
591 wxTextCompleter
*m_customCompleter
;
593 // Initially false, set to true after connecting OnTextChanged() handler.
594 bool m_connectedCharEvent
;
597 wxDECLARE_NO_COPY_CLASS(wxTextAutoCompleteData
);
600 #endif // HAS_AUTOCOMPLETE
602 // ============================================================================
603 // wxTextEntry implementation
604 // ============================================================================
606 // ----------------------------------------------------------------------------
607 // initialization and destruction
608 // ----------------------------------------------------------------------------
610 wxTextEntry::wxTextEntry()
612 #ifdef HAS_AUTOCOMPLETE
613 m_autoCompleteData
= NULL
;
614 #endif // HAS_AUTOCOMPLETE
617 wxTextEntry::~wxTextEntry()
619 #ifdef HAS_AUTOCOMPLETE
620 delete m_autoCompleteData
;
621 #endif // HAS_AUTOCOMPLETE
624 // ----------------------------------------------------------------------------
625 // operations on text
626 // ----------------------------------------------------------------------------
628 void wxTextEntry::WriteText(const wxString
& text
)
630 ::SendMessage(GetEditHwnd(), EM_REPLACESEL
, 0, wxMSW_CONV_LPARAM(text
));
633 wxString
wxTextEntry::DoGetValue() const
635 return wxGetWindowText(GetEditHWND());
638 void wxTextEntry::Remove(long from
, long to
)
640 DoSetSelection(from
, to
, SetSel_NoScroll
);
641 WriteText(wxString());
644 // ----------------------------------------------------------------------------
645 // clipboard operations
646 // ----------------------------------------------------------------------------
648 void wxTextEntry::Copy()
650 ::SendMessage(GetEditHwnd(), WM_COPY
, 0, 0);
653 void wxTextEntry::Cut()
655 ::SendMessage(GetEditHwnd(), WM_CUT
, 0, 0);
658 void wxTextEntry::Paste()
660 ::SendMessage(GetEditHwnd(), WM_PASTE
, 0, 0);
663 // ----------------------------------------------------------------------------
665 // ----------------------------------------------------------------------------
667 void wxTextEntry::Undo()
669 ::SendMessage(GetEditHwnd(), EM_UNDO
, 0, 0);
672 void wxTextEntry::Redo()
674 // same as Undo, since Undo undoes the undo
679 bool wxTextEntry::CanUndo() const
681 return ::SendMessage(GetEditHwnd(), EM_CANUNDO
, 0, 0) != 0;
684 bool wxTextEntry::CanRedo() const
686 // see comment in Redo()
690 // ----------------------------------------------------------------------------
691 // insertion point and selection
692 // ----------------------------------------------------------------------------
694 void wxTextEntry::SetInsertionPoint(long pos
)
696 // calling DoSetSelection(-1, -1) would select everything which is not what
699 pos
= GetLastPosition();
701 // be careful to call DoSetSelection() which is overridden in wxTextCtrl
702 // and not just SetSelection() here
703 DoSetSelection(pos
, pos
);
706 long wxTextEntry::GetInsertionPoint() const
709 GetSelection(&from
, NULL
);
713 long wxTextEntry::GetLastPosition() const
715 return ::SendMessage(GetEditHwnd(), EM_LINELENGTH
, 0, 0);
718 void wxTextEntry::DoSetSelection(long from
, long to
, int WXUNUSED(flags
))
720 // if from and to are both -1, it means (in wxWidgets) that all text should
721 // be selected, translate this into Windows convention
722 if ( (from
== -1) && (to
== -1) )
727 ::SendMessage(GetEditHwnd(), EM_SETSEL
, from
, to
);
730 void wxTextEntry::GetSelection(long *from
, long *to
) const
732 DWORD dwStart
, dwEnd
;
733 ::SendMessage(GetEditHwnd(), EM_GETSEL
, (WPARAM
)&dwStart
, (LPARAM
)&dwEnd
);
741 // ----------------------------------------------------------------------------
743 // ----------------------------------------------------------------------------
747 #ifdef HAS_AUTOCOMPLETE
749 #if wxUSE_DYNLIB_CLASS
751 bool wxTextEntry::DoAutoCompleteFileNames(int flags
)
753 typedef HRESULT (WINAPI
*SHAutoComplete_t
)(HWND
, DWORD
);
754 static SHAutoComplete_t s_pfnSHAutoComplete
= (SHAutoComplete_t
)-1;
755 static wxDynamicLibrary s_dllShlwapi
;
756 if ( s_pfnSHAutoComplete
== (SHAutoComplete_t
)-1 )
758 if ( !s_dllShlwapi
.Load(wxT("shlwapi.dll"), wxDL_VERBATIM
| wxDL_QUIET
) )
760 s_pfnSHAutoComplete
= NULL
;
764 wxDL_INIT_FUNC(s_pfn
, SHAutoComplete
, s_dllShlwapi
);
768 if ( !s_pfnSHAutoComplete
)
772 if ( flags
& wxFILE
)
773 dwFlags
|= SHACF_FILESYS_ONLY
;
774 else if ( flags
& wxDIR
)
775 dwFlags
|= SHACF_FILESYS_DIRS
;
778 wxFAIL_MSG(wxS("No flags for file name auto completion?"));
782 HRESULT hr
= (*s_pfnSHAutoComplete
)(GetEditHwnd(), dwFlags
);
785 wxLogApiError(wxT("SHAutoComplete()"), hr
);
790 // Disable the other kinds of completion now that we use the built-in file
792 if ( m_autoCompleteData
)
793 m_autoCompleteData
->DisableCompletion();
798 #endif // wxUSE_DYNLIB_CLASS
800 wxTextAutoCompleteData
*wxTextEntry::GetOrCreateCompleter()
802 if ( !m_autoCompleteData
)
804 wxTextAutoCompleteData
* const ac
= new wxTextAutoCompleteData(this);
806 m_autoCompleteData
= ac
;
811 return m_autoCompleteData
;
814 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
816 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
820 ac
->ChangeStrings(choices
);
825 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
827 // First deal with the case when we just want to disable auto-completion.
830 if ( m_autoCompleteData
)
831 m_autoCompleteData
->DisableCompletion();
832 //else: Nothing to do, we hadn't used auto-completion even before.
834 else // Have a valid completer.
836 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
839 // Delete the custom completer for consistency with the case when
840 // we succeed to avoid memory leaks in user code.
845 // This gives ownership of the custom completer to m_autoCompleteData.
846 if ( !ac
->ChangeCustomCompleter(completer
) )
853 #else // !HAS_AUTOCOMPLETE
855 // We still need to define stubs as we declared these overrides in the header.
857 bool wxTextEntry::DoAutoCompleteFileNames(int flags
)
859 return wxTextEntryBase::DoAutoCompleteFileNames(flags
);
862 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
864 return wxTextEntryBase::DoAutoCompleteStrings(choices
);
867 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
869 return wxTextEntryBase::DoAutoCompleteCustom(completer
);
872 #endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
876 // ----------------------------------------------------------------------------
878 // ----------------------------------------------------------------------------
880 bool wxTextEntry::IsEditable() const
882 return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE
) & ES_READONLY
);
885 void wxTextEntry::SetEditable(bool editable
)
887 ::SendMessage(GetEditHwnd(), EM_SETREADONLY
, !editable
, 0);
890 // ----------------------------------------------------------------------------
892 // ----------------------------------------------------------------------------
894 void wxTextEntry::SetMaxLength(unsigned long len
)
898 // this will set it to a platform-dependent maximum (much more
899 // than 64Kb under NT)
903 ::SendMessage(GetEditHwnd(), EM_LIMITTEXT
, len
, 0);
906 // ----------------------------------------------------------------------------
908 // ----------------------------------------------------------------------------
912 #ifndef EM_SETCUEBANNER
913 #define EM_SETCUEBANNER 0x1501
914 #define EM_GETCUEBANNER 0x1502
917 bool wxTextEntry::SetHint(const wxString
& hint
)
919 if ( wxUxThemeEngine::GetIfActive() )
921 // notice that this message always works with Unicode strings
923 // we always use TRUE for wParam to show the hint even when the window
924 // has focus, otherwise there would be no way to show the hint for the
925 // initially focused window
926 if ( ::SendMessage(GetEditHwnd(), EM_SETCUEBANNER
,
927 TRUE
, (LPARAM
)(const wchar_t *)hint
.wc_str()) )
931 return wxTextEntryBase::SetHint(hint
);
934 wxString
wxTextEntry::GetHint() const
936 if ( wxUxThemeEngine::GetIfActive() )
939 if ( ::SendMessage(GetEditHwnd(), EM_GETCUEBANNER
,
940 (WPARAM
)buf
, WXSIZEOF(buf
)) )
941 return wxString(buf
);
944 return wxTextEntryBase::GetHint();
948 #endif // wxUSE_UXTHEME
950 // ----------------------------------------------------------------------------
952 // ----------------------------------------------------------------------------
954 bool wxTextEntry::DoSetMargins(const wxPoint
& margins
)
956 #if !defined(__WXWINCE__)
959 if ( margins
.x
!= -1 )
961 // Set both horizontal margins to the given value, we don't distinguish
962 // between left and right margin at wx API level and it seems to be
963 // better to change both of them than only left one.
964 ::SendMessage(GetEditHwnd(), EM_SETMARGINS
,
965 EC_LEFTMARGIN
| EC_RIGHTMARGIN
,
966 MAKELONG(margins
.x
, margins
.x
));
969 if ( margins
.y
!= -1 )
980 wxPoint
wxTextEntry::DoGetMargins() const
982 #if !defined(__WXWINCE__)
983 LRESULT lResult
= ::SendMessage(GetEditHwnd(), EM_GETMARGINS
,
985 int left
= LOWORD(lResult
);
987 return wxPoint(left
, top
);
989 return wxPoint(-1, -1);
993 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX