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"
37 #include "wx/msw/private.h"
40 #include "wx/msw/uxtheme.h"
43 #define GetEditHwnd() ((HWND)(GetEditHWND()))
45 // ----------------------------------------------------------------------------
46 // Classes used by auto-completion implementation.
47 // ----------------------------------------------------------------------------
49 // standard VC6 SDK (WINVER == 0x0400) does not know about IAutoComplete
50 #if wxUSE_OLE && (WINVER >= 0x0500)
51 #define HAS_AUTOCOMPLETE
54 #ifdef HAS_AUTOCOMPLETE
56 #include "wx/msw/ole/oleutils.h"
59 #if defined(__MINGW32__) || defined (__WATCOMC__) || defined(__CYGWIN__)
60 // needed for IID_IAutoComplete, IID_IAutoComplete2 and ACO_AUTOSUGGEST
64 #ifndef ACO_UPDOWNKEYDROPSLIST
65 #define ACO_UPDOWNKEYDROPSLIST 0x20
68 #ifndef SHACF_FILESYS_ONLY
69 #define SHACF_FILESYS_ONLY 0x00000010
75 // Normally this interface and its IID are defined in shobjidl.h header file
76 // included in the platform SDK but MinGW and Cygwin don't have it so redefine
77 // the interface ourselves and, as long as we do it all, do it for all
78 // compilers to ensure we have the same behaviour for all of them and to avoid
79 // the need to check for concrete compilers and maybe even their versions.
80 class IAutoCompleteDropDown
: public IUnknown
83 virtual HRESULT wxSTDCALL
GetDropDownStatus(DWORD
*, LPWSTR
*) = 0;
84 virtual HRESULT wxSTDCALL
ResetEnumerator() = 0;
87 DEFINE_GUID(IID_IAutoCompleteDropDown
,
88 0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);
90 DEFINE_GUID(CLSID_AutoComplete
,
91 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62);
93 // Small helper class which can be used to ensure thread safety even when
94 // wxUSE_THREADS==0 (and hence wxCriticalSection does nothing).
98 CSLock(CRITICAL_SECTION
& cs
) : m_cs(&cs
)
100 ::EnterCriticalSection(m_cs
);
105 ::LeaveCriticalSection(m_cs
);
109 CRITICAL_SECTION
* const m_cs
;
111 wxDECLARE_NO_COPY_CLASS(CSLock
);
114 } // anonymity namespace
116 // Implementation of string enumerator used by wxTextAutoCompleteData. This
117 // class simply forwards to wxTextCompleter associated with it.
119 // Notice that Next() method of this class is called by IAutoComplete
120 // background thread and so we must care about thread safety here.
121 class wxIEnumString
: public IEnumString
129 void ChangeCompleter(wxTextCompleter
*completer
)
131 // Indicate to Next() that it should bail out as soon as possible.
133 CSLock
lock(m_csRestart
);
138 // Now try to enter this critical section to ensure that Next() doesn't
139 // use the old pointer any more before changing it (this is vital as
140 // the old pointer will be destroyed after we return).
141 CSLock
lock(m_csCompleter
);
143 m_completer
= completer
;
146 void UpdatePrefix(const wxString
& prefix
)
148 CSLock
lock(m_csRestart
);
150 // We simply store the prefix here and will really update during the
151 // next call to our Next() method as we want to call Start() from the
152 // worker thread to prevent the main UI thread from blocking while the
153 // completions are generated.
158 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG celt
,
162 if ( !rgelt
|| (!pceltFetched
&& celt
> 1) )
165 ULONG pceltFetchedDummy
;
167 pceltFetched
= &pceltFetchedDummy
;
171 CSLock
lock(m_csCompleter
);
173 if ( !RestartIfNeeded() )
178 // Stop iterating if we need to update completions anyhow.
182 const wxString s
= m_completer
->GetNext();
186 const wxWX2WCbuf wcbuf
= s
.wc_str();
187 const size_t size
= (wcslen(wcbuf
) + 1)*sizeof(wchar_t);
188 void *olestr
= CoTaskMemAlloc(size
);
190 return E_OUTOFMEMORY
;
192 memcpy(olestr
, wcbuf
, size
);
194 *rgelt
++ = static_cast<LPOLESTR
>(olestr
);
202 virtual HRESULT STDMETHODCALLTYPE
Skip(ULONG celt
)
207 CSLock
lock(m_csCompleter
);
209 if ( !RestartIfNeeded() )
217 if ( m_completer
->GetNext().empty() )
224 virtual HRESULT STDMETHODCALLTYPE
Reset()
226 CSLock
lock(m_csRestart
);
233 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumString
**ppEnum
)
238 CSLock
lock(m_csCompleter
);
240 wxIEnumString
* const e
= new wxIEnumString
;
243 e
->ChangeCompleter(m_completer
);
250 DECLARE_IUNKNOWN_METHODS
;
253 // dtor doesn't have to be virtual as we're only ever deleted from our own
254 // Release() and are not meant to be derived form anyhow, but making it
255 // virtual silences gcc warnings; making it private makes it impossible to
256 // (mistakenly) delete us directly instead of calling Release()
257 virtual ~wxIEnumString()
259 ::DeleteCriticalSection(&m_csRestart
);
260 ::DeleteCriticalSection(&m_csCompleter
);
263 // Common part of all ctors.
266 ::InitializeCriticalSection(&m_csCompleter
);
267 ::InitializeCriticalSection(&m_csRestart
);
273 // Restart completions generation if needed. Should be only called from
274 // inside m_csCompleter.
276 // If false is returned, it means that there are no completions and that
277 // wxTextCompleter::GetNext() shouldn't be called at all.
278 bool RestartIfNeeded()
286 CSLock
lock(m_csRestart
);
292 } // Release m_csRestart before calling Start() to avoid blocking
293 // the main thread in UpdatePrefix() during its execution.
298 rc
= m_completer
->Start(prefix
);
305 // Critical section protecting m_completer itself. It must be entered when
306 // using the pointer to ensure that we don't continue using a dangling one
307 // after it is destroyed.
308 CRITICAL_SECTION m_csCompleter
;
310 // The completer we delegate to for the completions generation. It is never
311 // NULL after the initial ChangeCompleter() call.
312 wxTextCompleter
*m_completer
;
315 // Critical section m_prefix and m_restart. It should be only entered for
316 // short periods of time, i.e. we shouldn't call any wxTextCompleter
317 // methods from inside, to prevent the main thread from blocking on it in
319 CRITICAL_SECTION m_csRestart
;
321 // If m_restart is true, we need to call wxTextCompleter::Start() with the
322 // given prefix to restart generating the completions.
325 // Notice that we use LONG and not bool here to ensure that reading this
326 // value is atomic (32 bit reads are atomic operations under all Windows
327 // versions but reading bool isn't necessarily).
331 wxDECLARE_NO_COPY_CLASS(wxIEnumString
);
334 BEGIN_IID_TABLE(wxIEnumString
)
339 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumString
)
342 // This class gathers the all auto-complete-related stuff we use. It is
343 // allocated on demand by wxTextEntry when AutoComplete() is called.
344 class wxTextAutoCompleteData wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
347 // The constructor associates us with the given text entry.
348 wxTextAutoCompleteData(wxTextEntry
*entry
)
350 m_win(entry
->GetEditableWindow())
352 m_autoComplete
= NULL
;
353 m_autoCompleteDropDown
= NULL
;
354 m_enumStrings
= NULL
;
356 m_fixedCompleter
= NULL
;
357 m_customCompleter
= NULL
;
359 m_connectedCharEvent
= false;
361 // Create an object exposing IAutoComplete interface which we'll later
362 // use to get IAutoComplete2 as the latter can't be created directly,
364 HRESULT hr
= CoCreateInstance
368 CLSCTX_INPROC_SERVER
,
370 reinterpret_cast<void **>(&m_autoComplete
)
374 wxLogApiError(wxT("CoCreateInstance(CLSID_AutoComplete)"), hr
);
378 // Create a string enumerator and initialize the completer with it.
379 m_enumStrings
= new wxIEnumString
;
380 m_enumStrings
->AddRef();
381 hr
= m_autoComplete
->Init(m_entry
->GetEditHWND(), m_enumStrings
,
385 wxLogApiError(wxT("IAutoComplete::Init"), hr
);
387 m_enumStrings
->Release();
388 m_enumStrings
= NULL
;
393 // As explained in DoRefresh(), we need to call IAutoCompleteDropDown::
394 // ResetEnumerator() if we want to be able to change the completions on
395 // the fly. In principle we could live without it, i.e. return true
396 // from IsOk() even if this QueryInterface() fails, but it doesn't look
397 // like this is ever going to have in practice anyhow as the shell-
398 // provided IAutoComplete always implements IAutoCompleteDropDown too.
399 hr
= m_autoComplete
->QueryInterface
401 IID_IAutoCompleteDropDown
,
402 reinterpret_cast<void **>(&m_autoCompleteDropDown
)
406 wxLogApiError(wxT("IAutoComplete::QI(IAutoCompleteDropDown)"), hr
);
410 // Finally set the completion options using IAutoComplete2.
411 IAutoComplete2
*pAutoComplete2
= NULL
;
412 hr
= m_autoComplete
->QueryInterface
415 reinterpret_cast<void **>(&pAutoComplete2
)
419 pAutoComplete2
->SetOptions(ACO_AUTOSUGGEST
|
421 ACO_UPDOWNKEYDROPSLIST
);
422 pAutoComplete2
->Release();
426 ~wxTextAutoCompleteData()
428 delete m_customCompleter
;
429 delete m_fixedCompleter
;
432 m_enumStrings
->Release();
433 if ( m_autoCompleteDropDown
)
434 m_autoCompleteDropDown
->Release();
435 if ( m_autoComplete
)
436 m_autoComplete
->Release();
439 // Must be called after creating this object to verify if initializing it
443 return m_autoComplete
&& m_autoCompleteDropDown
&& m_enumStrings
;
446 void ChangeStrings(const wxArrayString
& strings
)
448 if ( !m_fixedCompleter
)
449 m_fixedCompleter
= new wxTextCompleterFixed
;
451 m_fixedCompleter
->SetCompletions(strings
);
453 m_enumStrings
->ChangeCompleter(m_fixedCompleter
);
458 // Takes ownership of the pointer if it is non-NULL.
459 bool ChangeCustomCompleter(wxTextCompleter
*completer
)
461 // Ensure that the old completer is not used any more before deleting
463 m_enumStrings
->ChangeCompleter(completer
);
465 delete m_customCompleter
;
466 m_customCompleter
= completer
;
468 if ( m_customCompleter
)
470 // We postpone connecting to this event until we really need to do
471 // it (however we don't disconnect from it when we don't need it
472 // any more because we don't have wxUNBIND_OR_DISCONNECT_HACK...).
473 if ( !m_connectedCharEvent
)
475 m_connectedCharEvent
= true;
477 // Use the special wxEVT_AFTER_CHAR and not the usual
478 // wxEVT_CHAR here because we need to have the updated value of
479 // the text control in this handler in order to provide
480 // completions for the correct prefix and unfortunately we
481 // don't have any way to let DefWindowProc() run from our
482 // wxEVT_CHAR handler (as we must also let the other handlers
483 // defined at wx level run first).
485 // Notice that we can't use wxEVT_COMMAND_TEXT_UPDATED here
486 // neither as, due to our use of ACO_AUTOAPPEND, we get
487 // EN_CHANGE notifications from the control every time
488 // IAutoComplete auto-appends something to it.
489 wxBIND_OR_CONNECT_HACK(m_win
, wxEVT_AFTER_CHAR
,
491 wxTextAutoCompleteData::OnAfterChar
,
495 UpdateStringsFromCustomCompleter();
501 void DisableCompletion()
503 // We currently simply reset the list of possible strings as this seems
504 // to effectively disable auto-completion just fine. We could (and
505 // probably should) use IAutoComplete::Enable(FALSE) for this too but
506 // then we'd need to call Enable(TRUE) to turn it on back again later.
507 ChangeStrings(wxArrayString());
511 // Must be called after changing the values to be returned by wxIEnumString
512 // to really make the changes stick.
515 m_enumStrings
->Reset();
517 // This is completely and utterly not documented and in fact the
518 // current MSDN seems to try to discourage us from using it by saying
519 // that "there is no reason to use this method unless the drop-down
520 // list is currently visible" but actually we absolutely must call it
521 // to force the auto-completer (and not just its drop-down!) to refresh
522 // the list of completions which could have changed now. Without this
523 // call the new choices returned by GetCompletions() that hadn't been
524 // returned by it before are simply silently ignored.
525 m_autoCompleteDropDown
->ResetEnumerator();
528 // Update the strings returned by our string enumerator to correspond to
529 // the currently valid choices according to the custom completer.
530 void UpdateStringsFromCustomCompleter()
532 // As we use ACO_AUTOAPPEND, the selected part of the text is usually
533 // the one appended by us so don't consider it as part of the
534 // user-entered prefix.
536 m_entry
->GetSelection(&from
, &to
);
539 from
= m_entry
->GetLastPosition(); // Take all if no selection.
541 const wxString prefix
= m_entry
->GetRange(0, from
);
543 m_enumStrings
->UpdatePrefix(prefix
);
548 void OnAfterChar(wxKeyEvent
& event
)
550 // Notice that we must not refresh the completions when the user
551 // presses Backspace as this would result in adding back the just
552 // erased character(s) because of ACO_AUTOAPPEND option we use.
553 if ( m_customCompleter
&& event
.GetKeyCode() != WXK_BACK
)
554 UpdateStringsFromCustomCompleter();
560 // The text entry we're associated with.
561 wxTextEntry
* const m_entry
;
563 // The window of this text entry.
564 wxWindow
* const m_win
;
566 // The auto-completer object itself.
567 IAutoComplete
*m_autoComplete
;
569 // Its IAutoCompleteDropDown interface needed for ResetEnumerator() call.
570 IAutoCompleteDropDown
*m_autoCompleteDropDown
;
572 // Enumerator for strings currently used for auto-completion.
573 wxIEnumString
*m_enumStrings
;
575 // Fixed string completer or NULL if none.
576 wxTextCompleterFixed
*m_fixedCompleter
;
578 // Custom completer or NULL if none.
579 wxTextCompleter
*m_customCompleter
;
581 // Initially false, set to true after connecting OnTextChanged() handler.
582 bool m_connectedCharEvent
;
585 wxDECLARE_NO_COPY_CLASS(wxTextAutoCompleteData
);
588 #endif // HAS_AUTOCOMPLETE
590 // ============================================================================
591 // wxTextEntry implementation
592 // ============================================================================
594 // ----------------------------------------------------------------------------
595 // initialization and destruction
596 // ----------------------------------------------------------------------------
598 wxTextEntry::wxTextEntry()
600 #ifdef HAS_AUTOCOMPLETE
601 m_autoCompleteData
= NULL
;
602 #endif // HAS_AUTOCOMPLETE
605 wxTextEntry::~wxTextEntry()
607 #ifdef HAS_AUTOCOMPLETE
608 delete m_autoCompleteData
;
609 #endif // HAS_AUTOCOMPLETE
612 // ----------------------------------------------------------------------------
613 // operations on text
614 // ----------------------------------------------------------------------------
616 void wxTextEntry::WriteText(const wxString
& text
)
618 ::SendMessage(GetEditHwnd(), EM_REPLACESEL
, 0, (LPARAM
)text
.wx_str());
621 wxString
wxTextEntry::DoGetValue() const
623 return wxGetWindowText(GetEditHWND());
626 void wxTextEntry::Remove(long from
, long to
)
628 DoSetSelection(from
, to
, SetSel_NoScroll
);
629 WriteText(wxString());
632 // ----------------------------------------------------------------------------
633 // clipboard operations
634 // ----------------------------------------------------------------------------
636 void wxTextEntry::Copy()
638 ::SendMessage(GetEditHwnd(), WM_COPY
, 0, 0);
641 void wxTextEntry::Cut()
643 ::SendMessage(GetEditHwnd(), WM_CUT
, 0, 0);
646 void wxTextEntry::Paste()
648 ::SendMessage(GetEditHwnd(), WM_PASTE
, 0, 0);
651 // ----------------------------------------------------------------------------
653 // ----------------------------------------------------------------------------
655 void wxTextEntry::Undo()
657 ::SendMessage(GetEditHwnd(), EM_UNDO
, 0, 0);
660 void wxTextEntry::Redo()
662 // same as Undo, since Undo undoes the undo
667 bool wxTextEntry::CanUndo() const
669 return ::SendMessage(GetEditHwnd(), EM_CANUNDO
, 0, 0) != 0;
672 bool wxTextEntry::CanRedo() const
674 // see comment in Redo()
678 // ----------------------------------------------------------------------------
679 // insertion point and selection
680 // ----------------------------------------------------------------------------
682 void wxTextEntry::SetInsertionPoint(long pos
)
684 // calling DoSetSelection(-1, -1) would select everything which is not what
687 pos
= GetLastPosition();
689 // be careful to call DoSetSelection() which is overridden in wxTextCtrl
690 // and not just SetSelection() here
691 DoSetSelection(pos
, pos
);
694 long wxTextEntry::GetInsertionPoint() const
697 GetSelection(&from
, NULL
);
701 long wxTextEntry::GetLastPosition() const
703 return ::SendMessage(GetEditHwnd(), EM_LINELENGTH
, 0, 0);
706 void wxTextEntry::DoSetSelection(long from
, long to
, int WXUNUSED(flags
))
708 // if from and to are both -1, it means (in wxWidgets) that all text should
709 // be selected, translate this into Windows convention
710 if ( (from
== -1) && (to
== -1) )
715 ::SendMessage(GetEditHwnd(), EM_SETSEL
, from
, to
);
718 void wxTextEntry::GetSelection(long *from
, long *to
) const
720 DWORD dwStart
, dwEnd
;
721 ::SendMessage(GetEditHwnd(), EM_GETSEL
, (WPARAM
)&dwStart
, (LPARAM
)&dwEnd
);
729 // ----------------------------------------------------------------------------
731 // ----------------------------------------------------------------------------
735 #ifdef HAS_AUTOCOMPLETE
737 bool wxTextEntry::DoAutoCompleteFileNames()
739 typedef HRESULT (WINAPI
*SHAutoComplete_t
)(HWND
, DWORD
);
740 static SHAutoComplete_t s_pfnSHAutoComplete
= (SHAutoComplete_t
)-1;
741 static wxDynamicLibrary s_dllShlwapi
;
742 if ( s_pfnSHAutoComplete
== (SHAutoComplete_t
)-1 )
744 if ( !s_dllShlwapi
.Load(wxT("shlwapi.dll"), wxDL_VERBATIM
| wxDL_QUIET
) )
746 s_pfnSHAutoComplete
= NULL
;
750 wxDL_INIT_FUNC(s_pfn
, SHAutoComplete
, s_dllShlwapi
);
754 if ( !s_pfnSHAutoComplete
)
757 HRESULT hr
= (*s_pfnSHAutoComplete
)(GetEditHwnd(), SHACF_FILESYS_ONLY
);
760 wxLogApiError(wxT("SHAutoComplete()"), hr
);
765 // Disable the other kinds of completion now that we use the built-in file
767 if ( m_autoCompleteData
)
768 m_autoCompleteData
->DisableCompletion();
773 wxTextAutoCompleteData
*wxTextEntry::GetOrCreateCompleter()
775 if ( !m_autoCompleteData
)
777 wxTextAutoCompleteData
* const ac
= new wxTextAutoCompleteData(this);
779 m_autoCompleteData
= ac
;
784 return m_autoCompleteData
;
787 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
789 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
793 ac
->ChangeStrings(choices
);
798 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
800 // First deal with the case when we just want to disable auto-completion.
803 if ( m_autoCompleteData
)
804 m_autoCompleteData
->DisableCompletion();
805 //else: Nothing to do, we hadn't used auto-completion even before.
807 else // Have a valid completer.
809 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
812 // Delete the custom completer for consistency with the case when
813 // we succeed to avoid memory leaks in user code.
818 // This gives ownership of the custom completer to m_autoCompleteData.
819 if ( !ac
->ChangeCustomCompleter(completer
) )
826 #else // !HAS_AUTOCOMPLETE
828 // We still need to define stubs as we declared these overrides in the header.
830 bool wxTextEntry::DoAutoCompleteFileNames()
832 return wxTextEntryBase::DoAutoCompleteFileNames();
835 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
837 return wxTextEntryBase::DoAutoCompleteStrings(choices
);
840 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
842 return wxTextEntryBase::DoAutoCompleteCustom(completer
);
845 #endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
849 // ----------------------------------------------------------------------------
851 // ----------------------------------------------------------------------------
853 bool wxTextEntry::IsEditable() const
855 return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE
) & ES_READONLY
);
858 void wxTextEntry::SetEditable(bool editable
)
860 ::SendMessage(GetEditHwnd(), EM_SETREADONLY
, !editable
, 0);
863 // ----------------------------------------------------------------------------
865 // ----------------------------------------------------------------------------
867 void wxTextEntry::SetMaxLength(unsigned long len
)
871 // this will set it to a platform-dependent maximum (much more
872 // than 64Kb under NT)
876 ::SendMessage(GetEditHwnd(), EM_LIMITTEXT
, len
, 0);
879 // ----------------------------------------------------------------------------
881 // ----------------------------------------------------------------------------
885 #ifndef EM_SETCUEBANNER
886 #define EM_SETCUEBANNER 0x1501
887 #define EM_GETCUEBANNER 0x1502
890 bool wxTextEntry::SetHint(const wxString
& hint
)
892 if ( wxUxThemeEngine::GetIfActive() )
894 // notice that this message always works with Unicode strings
896 // we always use TRUE for wParam to show the hint even when the window
897 // has focus, otherwise there would be no way to show the hint for the
898 // initially focused window
899 if ( ::SendMessage(GetEditHwnd(), EM_SETCUEBANNER
,
900 TRUE
, (LPARAM
)(const wchar_t *)hint
.wc_str()) )
904 return wxTextEntryBase::SetHint(hint
);
907 wxString
wxTextEntry::GetHint() const
909 if ( wxUxThemeEngine::GetIfActive() )
912 if ( ::SendMessage(GetEditHwnd(), EM_GETCUEBANNER
,
913 (WPARAM
)buf
, WXSIZEOF(buf
)) )
914 return wxString(buf
);
917 return wxTextEntryBase::GetHint();
921 #endif // wxUSE_UXTHEME
923 // ----------------------------------------------------------------------------
925 // ----------------------------------------------------------------------------
927 bool wxTextEntry::DoSetMargins(const wxPoint
& margins
)
929 #if !defined(__WXWINCE__)
932 if ( margins
.x
!= -1 )
935 ::SendMessage(GetEditHwnd(), EM_SETMARGINS
,
936 EC_LEFTMARGIN
, MAKELONG(margins
.x
, 0));
939 if ( margins
.y
!= -1 )
950 wxPoint
wxTextEntry::DoGetMargins() const
952 #if !defined(__WXWINCE__)
953 LRESULT lResult
= ::SendMessage(GetEditHwnd(), EM_GETMARGINS
,
955 int left
= LOWORD(lResult
);
957 return wxPoint(left
, top
);
959 return wxPoint(-1, -1);
963 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX