1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/textentry.cpp
3 // Purpose: wxTextEntry implementation for wxMSW
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/arrstr.h"
28 #include "wx/string.h"
31 #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
33 #include "wx/textentry.h"
34 #include "wx/textcompleter.h"
35 #include "wx/dynlib.h"
39 #include "wx/msw/private.h"
42 #include "wx/msw/uxtheme.h"
45 #define GetEditHwnd() ((HWND)(GetEditHWND()))
47 // ----------------------------------------------------------------------------
48 // Classes used by auto-completion implementation.
49 // ----------------------------------------------------------------------------
51 // standard VC6 SDK (WINVER == 0x0400) does not know about IAutoComplete
52 #if wxUSE_OLE && (WINVER >= 0x0500)
53 #define HAS_AUTOCOMPLETE
56 #ifdef HAS_AUTOCOMPLETE
58 #include "wx/msw/ole/oleutils.h"
61 #if defined(__MINGW32__) || defined (__WATCOMC__) || defined(__CYGWIN__)
62 // needed for IID_IAutoComplete, IID_IAutoComplete2 and ACO_AUTOSUGGEST
65 #ifndef ACO_AUTOAPPEND
66 #define ACO_AUTOAPPEND 0x02
70 #ifndef ACO_UPDOWNKEYDROPSLIST
71 #define ACO_UPDOWNKEYDROPSLIST 0x20
74 #ifndef SHACF_FILESYS_ONLY
75 #define SHACF_FILESYS_ONLY 0x00000010
78 #ifndef SHACF_FILESYS_DIRS
79 #define SHACF_FILESYS_DIRS 0x00000020
85 // Normally this interface and its IID are defined in shobjidl.h header file
86 // included in the platform SDK but MinGW and Cygwin don't have it so redefine
87 // the interface ourselves and, as long as we do it all, do it for all
88 // compilers to ensure we have the same behaviour for all of them and to avoid
89 // the need to check for concrete compilers and maybe even their versions.
90 class IAutoCompleteDropDown
: public IUnknown
93 virtual HRESULT wxSTDCALL
GetDropDownStatus(DWORD
*, LPWSTR
*) = 0;
94 virtual HRESULT wxSTDCALL
ResetEnumerator() = 0;
97 DEFINE_GUID(wxIID_IAutoCompleteDropDown
,
98 0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);
100 DEFINE_GUID(wxCLSID_AutoComplete
,
101 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62);
103 // Small helper class which can be used to ensure thread safety even when
104 // wxUSE_THREADS==0 (and hence wxCriticalSection does nothing).
108 CSLock(CRITICAL_SECTION
& cs
) : m_cs(&cs
)
110 ::EnterCriticalSection(m_cs
);
115 ::LeaveCriticalSection(m_cs
);
119 CRITICAL_SECTION
* const m_cs
;
121 wxDECLARE_NO_COPY_CLASS(CSLock
);
124 } // anonymity namespace
126 // Implementation of string enumerator used by wxTextAutoCompleteData. This
127 // class simply forwards to wxTextCompleter associated with it.
129 // Notice that Next() method of this class is called by IAutoComplete
130 // background thread and so we must care about thread safety here.
131 class wxIEnumString
: public IEnumString
139 void ChangeCompleter(wxTextCompleter
*completer
)
141 // Indicate to Next() that it should bail out as soon as possible.
143 CSLock
lock(m_csRestart
);
148 // Now try to enter this critical section to ensure that Next() doesn't
149 // use the old pointer any more before changing it (this is vital as
150 // the old pointer will be destroyed after we return).
151 CSLock
lock(m_csCompleter
);
153 m_completer
= completer
;
156 void UpdatePrefix(const wxString
& prefix
)
158 CSLock
lock(m_csRestart
);
160 // We simply store the prefix here and will really update during the
161 // next call to our Next() method as we want to call Start() from the
162 // worker thread to prevent the main UI thread from blocking while the
163 // completions are generated.
168 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG celt
,
172 if ( !rgelt
|| (!pceltFetched
&& celt
> 1) )
175 ULONG pceltFetchedDummy
;
177 pceltFetched
= &pceltFetchedDummy
;
181 CSLock
lock(m_csCompleter
);
183 if ( !RestartIfNeeded() )
188 // Stop iterating if we need to update completions anyhow.
192 const wxString s
= m_completer
->GetNext();
196 const wxWX2WCbuf wcbuf
= s
.wc_str();
197 const size_t size
= (wcslen(wcbuf
) + 1)*sizeof(wchar_t);
198 void *olestr
= CoTaskMemAlloc(size
);
200 return E_OUTOFMEMORY
;
202 memcpy(olestr
, wcbuf
, size
);
204 *rgelt
++ = static_cast<LPOLESTR
>(olestr
);
212 virtual HRESULT STDMETHODCALLTYPE
Skip(ULONG celt
)
217 CSLock
lock(m_csCompleter
);
219 if ( !RestartIfNeeded() )
227 if ( m_completer
->GetNext().empty() )
234 virtual HRESULT STDMETHODCALLTYPE
Reset()
236 CSLock
lock(m_csRestart
);
243 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumString
**ppEnum
)
248 CSLock
lock(m_csCompleter
);
250 wxIEnumString
* const e
= new wxIEnumString
;
253 e
->ChangeCompleter(m_completer
);
260 DECLARE_IUNKNOWN_METHODS
;
263 // dtor doesn't have to be virtual as we're only ever deleted from our own
264 // Release() and are not meant to be derived form anyhow, but making it
265 // virtual silences gcc warnings; making it private makes it impossible to
266 // (mistakenly) delete us directly instead of calling Release()
267 virtual ~wxIEnumString()
269 ::DeleteCriticalSection(&m_csRestart
);
270 ::DeleteCriticalSection(&m_csCompleter
);
273 // Common part of all ctors.
276 ::InitializeCriticalSection(&m_csCompleter
);
277 ::InitializeCriticalSection(&m_csRestart
);
283 // Restart completions generation if needed. Should be only called from
284 // inside m_csCompleter.
286 // If false is returned, it means that there are no completions and that
287 // wxTextCompleter::GetNext() shouldn't be called at all.
288 bool RestartIfNeeded()
296 CSLock
lock(m_csRestart
);
302 } // Release m_csRestart before calling Start() to avoid blocking
303 // the main thread in UpdatePrefix() during its execution.
308 rc
= m_completer
->Start(prefix
);
315 // Critical section protecting m_completer itself. It must be entered when
316 // using the pointer to ensure that we don't continue using a dangling one
317 // after it is destroyed.
318 CRITICAL_SECTION m_csCompleter
;
320 // The completer we delegate to for the completions generation. It is never
321 // NULL after the initial ChangeCompleter() call.
322 wxTextCompleter
*m_completer
;
325 // Critical section m_prefix and m_restart. It should be only entered for
326 // short periods of time, i.e. we shouldn't call any wxTextCompleter
327 // methods from inside, to prevent the main thread from blocking on it in
329 CRITICAL_SECTION m_csRestart
;
331 // If m_restart is true, we need to call wxTextCompleter::Start() with the
332 // given prefix to restart generating the completions.
335 // Notice that we use LONG and not bool here to ensure that reading this
336 // value is atomic (32 bit reads are atomic operations under all Windows
337 // versions but reading bool isn't necessarily).
341 wxDECLARE_NO_COPY_CLASS(wxIEnumString
);
344 BEGIN_IID_TABLE(wxIEnumString
)
349 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumString
)
352 // This class gathers the all auto-complete-related stuff we use. It is
353 // allocated on demand by wxTextEntry when AutoComplete() is called.
354 class wxTextAutoCompleteData wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
357 // The constructor associates us with the given text entry.
358 wxTextAutoCompleteData(wxTextEntry
*entry
)
360 m_win(entry
->GetEditableWindow())
362 m_autoComplete
= NULL
;
363 m_autoCompleteDropDown
= NULL
;
364 m_enumStrings
= NULL
;
366 m_fixedCompleter
= NULL
;
367 m_customCompleter
= NULL
;
369 m_connectedCharEvent
= false;
371 // Create an object exposing IAutoComplete interface which we'll later
372 // use to get IAutoComplete2 as the latter can't be created directly,
374 HRESULT hr
= CoCreateInstance
376 wxCLSID_AutoComplete
,
378 CLSCTX_INPROC_SERVER
,
380 reinterpret_cast<void **>(&m_autoComplete
)
384 wxLogApiError(wxT("CoCreateInstance(CLSID_AutoComplete)"), hr
);
388 // Create a string enumerator and initialize the completer with it.
389 m_enumStrings
= new wxIEnumString
;
390 m_enumStrings
->AddRef();
391 hr
= m_autoComplete
->Init(m_entry
->GetEditHWND(), m_enumStrings
,
395 wxLogApiError(wxT("IAutoComplete::Init"), hr
);
397 m_enumStrings
->Release();
398 m_enumStrings
= NULL
;
403 // As explained in DoRefresh(), we need to call IAutoCompleteDropDown::
404 // ResetEnumerator() if we want to be able to change the completions on
405 // the fly. In principle we could live without it, i.e. return true
406 // from IsOk() even if this QueryInterface() fails, but it doesn't look
407 // like this is ever going to have in practice anyhow as the shell-
408 // provided IAutoComplete always implements IAutoCompleteDropDown too.
409 hr
= m_autoComplete
->QueryInterface
411 wxIID_IAutoCompleteDropDown
,
412 reinterpret_cast<void **>(&m_autoCompleteDropDown
)
416 wxLogApiError(wxT("IAutoComplete::QI(IAutoCompleteDropDown)"), hr
);
420 // Finally set the completion options using IAutoComplete2.
421 IAutoComplete2
*pAutoComplete2
= NULL
;
422 hr
= m_autoComplete
->QueryInterface
425 reinterpret_cast<void **>(&pAutoComplete2
)
429 pAutoComplete2
->SetOptions(ACO_AUTOSUGGEST
|
431 ACO_UPDOWNKEYDROPSLIST
);
432 pAutoComplete2
->Release();
436 ~wxTextAutoCompleteData()
438 delete m_customCompleter
;
439 delete m_fixedCompleter
;
442 m_enumStrings
->Release();
443 if ( m_autoCompleteDropDown
)
444 m_autoCompleteDropDown
->Release();
445 if ( m_autoComplete
)
446 m_autoComplete
->Release();
449 // Must be called after creating this object to verify if initializing it
453 return m_autoComplete
&& m_autoCompleteDropDown
&& m_enumStrings
;
456 void ChangeStrings(const wxArrayString
& strings
)
458 if ( !m_fixedCompleter
)
459 m_fixedCompleter
= new wxTextCompleterFixed
;
461 m_fixedCompleter
->SetCompletions(strings
);
463 m_enumStrings
->ChangeCompleter(m_fixedCompleter
);
468 // Takes ownership of the pointer if it is non-NULL.
469 bool ChangeCustomCompleter(wxTextCompleter
*completer
)
471 // Ensure that the old completer is not used any more before deleting
473 m_enumStrings
->ChangeCompleter(completer
);
475 delete m_customCompleter
;
476 m_customCompleter
= completer
;
478 if ( m_customCompleter
)
480 // We postpone connecting to this event until we really need to do
481 // it (however we don't disconnect from it when we don't need it
482 // any more because we don't have wxUNBIND_OR_DISCONNECT_HACK...).
483 if ( !m_connectedCharEvent
)
485 m_connectedCharEvent
= true;
487 // Use the special wxEVT_AFTER_CHAR and not the usual
488 // wxEVT_CHAR here because we need to have the updated value of
489 // the text control in this handler in order to provide
490 // completions for the correct prefix and unfortunately we
491 // don't have any way to let DefWindowProc() run from our
492 // wxEVT_CHAR handler (as we must also let the other handlers
493 // defined at wx level run first).
495 // Notice that we can't use wxEVT_COMMAND_TEXT_UPDATED here
496 // neither as, due to our use of ACO_AUTOAPPEND, we get
497 // EN_CHANGE notifications from the control every time
498 // IAutoComplete auto-appends something to it.
499 wxBIND_OR_CONNECT_HACK(m_win
, wxEVT_AFTER_CHAR
,
501 wxTextAutoCompleteData::OnAfterChar
,
505 UpdateStringsFromCustomCompleter();
511 void DisableCompletion()
513 // We currently simply reset the list of possible strings as this seems
514 // to effectively disable auto-completion just fine. We could (and
515 // probably should) use IAutoComplete::Enable(FALSE) for this too but
516 // then we'd need to call Enable(TRUE) to turn it on back again later.
517 ChangeStrings(wxArrayString());
521 // Must be called after changing the values to be returned by wxIEnumString
522 // to really make the changes stick.
525 m_enumStrings
->Reset();
527 // This is completely and utterly not documented and in fact the
528 // current MSDN seems to try to discourage us from using it by saying
529 // that "there is no reason to use this method unless the drop-down
530 // list is currently visible" but actually we absolutely must call it
531 // to force the auto-completer (and not just its drop-down!) to refresh
532 // the list of completions which could have changed now. Without this
533 // call the new choices returned by GetCompletions() that hadn't been
534 // returned by it before are simply silently ignored.
535 m_autoCompleteDropDown
->ResetEnumerator();
538 // Update the strings returned by our string enumerator to correspond to
539 // the currently valid choices according to the custom completer.
540 void UpdateStringsFromCustomCompleter()
542 // As we use ACO_AUTOAPPEND, the selected part of the text is usually
543 // the one appended by us so don't consider it as part of the
544 // user-entered prefix.
546 m_entry
->GetSelection(&from
, &to
);
549 from
= m_entry
->GetLastPosition(); // Take all if no selection.
551 const wxString prefix
= m_entry
->GetRange(0, from
);
553 m_enumStrings
->UpdatePrefix(prefix
);
558 void OnAfterChar(wxKeyEvent
& event
)
560 // Notice that we must not refresh the completions when the user
561 // presses Backspace as this would result in adding back the just
562 // erased character(s) because of ACO_AUTOAPPEND option we use.
563 if ( m_customCompleter
&& event
.GetKeyCode() != WXK_BACK
)
564 UpdateStringsFromCustomCompleter();
570 // The text entry we're associated with.
571 wxTextEntry
* const m_entry
;
573 // The window of this text entry.
574 wxWindow
* const m_win
;
576 // The auto-completer object itself.
577 IAutoComplete
*m_autoComplete
;
579 // Its IAutoCompleteDropDown interface needed for ResetEnumerator() call.
580 IAutoCompleteDropDown
*m_autoCompleteDropDown
;
582 // Enumerator for strings currently used for auto-completion.
583 wxIEnumString
*m_enumStrings
;
585 // Fixed string completer or NULL if none.
586 wxTextCompleterFixed
*m_fixedCompleter
;
588 // Custom completer or NULL if none.
589 wxTextCompleter
*m_customCompleter
;
591 // Initially false, set to true after connecting OnTextChanged() handler.
592 bool m_connectedCharEvent
;
595 wxDECLARE_NO_COPY_CLASS(wxTextAutoCompleteData
);
598 #endif // HAS_AUTOCOMPLETE
600 // ============================================================================
601 // wxTextEntry implementation
602 // ============================================================================
604 // ----------------------------------------------------------------------------
605 // initialization and destruction
606 // ----------------------------------------------------------------------------
608 wxTextEntry::wxTextEntry()
610 #ifdef HAS_AUTOCOMPLETE
611 m_autoCompleteData
= NULL
;
612 #endif // HAS_AUTOCOMPLETE
615 wxTextEntry::~wxTextEntry()
617 #ifdef HAS_AUTOCOMPLETE
618 delete m_autoCompleteData
;
619 #endif // HAS_AUTOCOMPLETE
622 // ----------------------------------------------------------------------------
623 // operations on text
624 // ----------------------------------------------------------------------------
626 void wxTextEntry::WriteText(const wxString
& text
)
628 ::SendMessage(GetEditHwnd(), EM_REPLACESEL
, 0, wxMSW_CONV_LPARAM(text
));
631 wxString
wxTextEntry::DoGetValue() const
633 return wxGetWindowText(GetEditHWND());
636 void wxTextEntry::Remove(long from
, long to
)
638 DoSetSelection(from
, to
, SetSel_NoScroll
);
639 WriteText(wxString());
642 // ----------------------------------------------------------------------------
643 // clipboard operations
644 // ----------------------------------------------------------------------------
646 void wxTextEntry::Copy()
648 ::SendMessage(GetEditHwnd(), WM_COPY
, 0, 0);
651 void wxTextEntry::Cut()
653 ::SendMessage(GetEditHwnd(), WM_CUT
, 0, 0);
656 void wxTextEntry::Paste()
658 ::SendMessage(GetEditHwnd(), WM_PASTE
, 0, 0);
661 // ----------------------------------------------------------------------------
663 // ----------------------------------------------------------------------------
665 void wxTextEntry::Undo()
667 ::SendMessage(GetEditHwnd(), EM_UNDO
, 0, 0);
670 void wxTextEntry::Redo()
672 // same as Undo, since Undo undoes the undo
677 bool wxTextEntry::CanUndo() const
679 return ::SendMessage(GetEditHwnd(), EM_CANUNDO
, 0, 0) != 0;
682 bool wxTextEntry::CanRedo() const
684 // see comment in Redo()
688 // ----------------------------------------------------------------------------
689 // insertion point and selection
690 // ----------------------------------------------------------------------------
692 void wxTextEntry::SetInsertionPoint(long pos
)
694 // calling DoSetSelection(-1, -1) would select everything which is not what
697 pos
= GetLastPosition();
699 // be careful to call DoSetSelection() which is overridden in wxTextCtrl
700 // and not just SetSelection() here
701 DoSetSelection(pos
, pos
);
704 long wxTextEntry::GetInsertionPoint() const
707 GetSelection(&from
, NULL
);
711 long wxTextEntry::GetLastPosition() const
713 return ::SendMessage(GetEditHwnd(), EM_LINELENGTH
, 0, 0);
716 void wxTextEntry::DoSetSelection(long from
, long to
, int WXUNUSED(flags
))
718 // if from and to are both -1, it means (in wxWidgets) that all text should
719 // be selected, translate this into Windows convention
720 if ( (from
== -1) && (to
== -1) )
725 ::SendMessage(GetEditHwnd(), EM_SETSEL
, from
, to
);
728 void wxTextEntry::GetSelection(long *from
, long *to
) const
730 DWORD dwStart
, dwEnd
;
731 ::SendMessage(GetEditHwnd(), EM_GETSEL
, (WPARAM
)&dwStart
, (LPARAM
)&dwEnd
);
739 // ----------------------------------------------------------------------------
741 // ----------------------------------------------------------------------------
745 #ifdef HAS_AUTOCOMPLETE
747 #if wxUSE_DYNLIB_CLASS
749 bool wxTextEntry::DoAutoCompleteFileNames(int flags
)
751 typedef HRESULT (WINAPI
*SHAutoComplete_t
)(HWND
, DWORD
);
752 static SHAutoComplete_t s_pfnSHAutoComplete
= (SHAutoComplete_t
)-1;
753 static wxDynamicLibrary s_dllShlwapi
;
754 if ( s_pfnSHAutoComplete
== (SHAutoComplete_t
)-1 )
756 if ( !s_dllShlwapi
.Load(wxT("shlwapi.dll"), wxDL_VERBATIM
| wxDL_QUIET
) )
758 s_pfnSHAutoComplete
= NULL
;
762 wxDL_INIT_FUNC(s_pfn
, SHAutoComplete
, s_dllShlwapi
);
766 if ( !s_pfnSHAutoComplete
)
770 if ( flags
& wxFILE
)
771 dwFlags
|= SHACF_FILESYS_ONLY
;
772 else if ( flags
& wxDIR
)
773 dwFlags
|= SHACF_FILESYS_DIRS
;
776 wxFAIL_MSG(wxS("No flags for file name auto completion?"));
780 HRESULT hr
= (*s_pfnSHAutoComplete
)(GetEditHwnd(), dwFlags
);
783 wxLogApiError(wxT("SHAutoComplete()"), hr
);
788 // Disable the other kinds of completion now that we use the built-in file
790 if ( m_autoCompleteData
)
791 m_autoCompleteData
->DisableCompletion();
796 #endif // wxUSE_DYNLIB_CLASS
798 wxTextAutoCompleteData
*wxTextEntry::GetOrCreateCompleter()
800 if ( !m_autoCompleteData
)
802 wxTextAutoCompleteData
* const ac
= new wxTextAutoCompleteData(this);
804 m_autoCompleteData
= ac
;
809 return m_autoCompleteData
;
812 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
814 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
818 ac
->ChangeStrings(choices
);
823 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
825 // First deal with the case when we just want to disable auto-completion.
828 if ( m_autoCompleteData
)
829 m_autoCompleteData
->DisableCompletion();
830 //else: Nothing to do, we hadn't used auto-completion even before.
832 else // Have a valid completer.
834 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
837 // Delete the custom completer for consistency with the case when
838 // we succeed to avoid memory leaks in user code.
843 // This gives ownership of the custom completer to m_autoCompleteData.
844 if ( !ac
->ChangeCustomCompleter(completer
) )
851 #else // !HAS_AUTOCOMPLETE
853 // We still need to define stubs as we declared these overrides in the header.
855 bool wxTextEntry::DoAutoCompleteFileNames(int flags
)
857 return wxTextEntryBase::DoAutoCompleteFileNames(flags
);
860 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
862 return wxTextEntryBase::DoAutoCompleteStrings(choices
);
865 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
867 return wxTextEntryBase::DoAutoCompleteCustom(completer
);
870 #endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
874 // ----------------------------------------------------------------------------
876 // ----------------------------------------------------------------------------
878 bool wxTextEntry::IsEditable() const
880 return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE
) & ES_READONLY
);
883 void wxTextEntry::SetEditable(bool editable
)
885 ::SendMessage(GetEditHwnd(), EM_SETREADONLY
, !editable
, 0);
888 // ----------------------------------------------------------------------------
890 // ----------------------------------------------------------------------------
892 void wxTextEntry::SetMaxLength(unsigned long len
)
896 // this will set it to a platform-dependent maximum (much more
897 // than 64Kb under NT)
901 ::SendMessage(GetEditHwnd(), EM_LIMITTEXT
, len
, 0);
904 // ----------------------------------------------------------------------------
906 // ----------------------------------------------------------------------------
910 #ifndef EM_SETCUEBANNER
911 #define EM_SETCUEBANNER 0x1501
912 #define EM_GETCUEBANNER 0x1502
915 bool wxTextEntry::SetHint(const wxString
& hint
)
917 if ( wxUxThemeEngine::GetIfActive() )
919 // notice that this message always works with Unicode strings
921 // we always use TRUE for wParam to show the hint even when the window
922 // has focus, otherwise there would be no way to show the hint for the
923 // initially focused window
924 if ( ::SendMessage(GetEditHwnd(), EM_SETCUEBANNER
,
925 TRUE
, (LPARAM
)(const wchar_t *)hint
.wc_str()) )
929 return wxTextEntryBase::SetHint(hint
);
932 wxString
wxTextEntry::GetHint() const
934 if ( wxUxThemeEngine::GetIfActive() )
937 if ( ::SendMessage(GetEditHwnd(), EM_GETCUEBANNER
,
938 (WPARAM
)buf
, WXSIZEOF(buf
)) )
939 return wxString(buf
);
942 return wxTextEntryBase::GetHint();
946 #endif // wxUSE_UXTHEME
948 // ----------------------------------------------------------------------------
950 // ----------------------------------------------------------------------------
952 bool wxTextEntry::DoSetMargins(const wxPoint
& margins
)
954 #if !defined(__WXWINCE__)
957 if ( margins
.x
!= -1 )
960 ::SendMessage(GetEditHwnd(), EM_SETMARGINS
,
961 EC_LEFTMARGIN
, MAKELONG(margins
.x
, 0));
964 if ( margins
.y
!= -1 )
975 wxPoint
wxTextEntry::DoGetMargins() const
977 #if !defined(__WXWINCE__)
978 LRESULT lResult
= ::SendMessage(GetEditHwnd(), EM_GETMARGINS
,
980 int left
= LOWORD(lResult
);
982 return wxPoint(left
, top
);
984 return wxPoint(-1, -1);
988 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX