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
81 // Normally this interface and its IID are defined in shobjidl.h header file
82 // included in the platform SDK but MinGW and Cygwin don't have it so redefine
83 // the interface ourselves and, as long as we do it all, do it for all
84 // compilers to ensure we have the same behaviour for all of them and to avoid
85 // the need to check for concrete compilers and maybe even their versions.
86 class IAutoCompleteDropDown
: public IUnknown
89 virtual HRESULT wxSTDCALL
GetDropDownStatus(DWORD
*, LPWSTR
*) = 0;
90 virtual HRESULT wxSTDCALL
ResetEnumerator() = 0;
93 DEFINE_GUID(wxIID_IAutoCompleteDropDown
,
94 0x3cd141f4, 0x3c6a, 0x11d2, 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb);
96 DEFINE_GUID(wxCLSID_AutoComplete
,
97 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62);
99 // Small helper class which can be used to ensure thread safety even when
100 // wxUSE_THREADS==0 (and hence wxCriticalSection does nothing).
104 CSLock(CRITICAL_SECTION
& cs
) : m_cs(&cs
)
106 ::EnterCriticalSection(m_cs
);
111 ::LeaveCriticalSection(m_cs
);
115 CRITICAL_SECTION
* const m_cs
;
117 wxDECLARE_NO_COPY_CLASS(CSLock
);
120 } // anonymity namespace
122 // Implementation of string enumerator used by wxTextAutoCompleteData. This
123 // class simply forwards to wxTextCompleter associated with it.
125 // Notice that Next() method of this class is called by IAutoComplete
126 // background thread and so we must care about thread safety here.
127 class wxIEnumString
: public IEnumString
135 void ChangeCompleter(wxTextCompleter
*completer
)
137 // Indicate to Next() that it should bail out as soon as possible.
139 CSLock
lock(m_csRestart
);
144 // Now try to enter this critical section to ensure that Next() doesn't
145 // use the old pointer any more before changing it (this is vital as
146 // the old pointer will be destroyed after we return).
147 CSLock
lock(m_csCompleter
);
149 m_completer
= completer
;
152 void UpdatePrefix(const wxString
& prefix
)
154 CSLock
lock(m_csRestart
);
156 // We simply store the prefix here and will really update during the
157 // next call to our Next() method as we want to call Start() from the
158 // worker thread to prevent the main UI thread from blocking while the
159 // completions are generated.
164 virtual HRESULT STDMETHODCALLTYPE
Next(ULONG celt
,
168 if ( !rgelt
|| (!pceltFetched
&& celt
> 1) )
171 ULONG pceltFetchedDummy
;
173 pceltFetched
= &pceltFetchedDummy
;
177 CSLock
lock(m_csCompleter
);
179 if ( !RestartIfNeeded() )
184 // Stop iterating if we need to update completions anyhow.
188 const wxString s
= m_completer
->GetNext();
192 const wxWX2WCbuf wcbuf
= s
.wc_str();
193 const size_t size
= (wcslen(wcbuf
) + 1)*sizeof(wchar_t);
194 void *olestr
= CoTaskMemAlloc(size
);
196 return E_OUTOFMEMORY
;
198 memcpy(olestr
, wcbuf
, size
);
200 *rgelt
++ = static_cast<LPOLESTR
>(olestr
);
208 virtual HRESULT STDMETHODCALLTYPE
Skip(ULONG celt
)
213 CSLock
lock(m_csCompleter
);
215 if ( !RestartIfNeeded() )
223 if ( m_completer
->GetNext().empty() )
230 virtual HRESULT STDMETHODCALLTYPE
Reset()
232 CSLock
lock(m_csRestart
);
239 virtual HRESULT STDMETHODCALLTYPE
Clone(IEnumString
**ppEnum
)
244 CSLock
lock(m_csCompleter
);
246 wxIEnumString
* const e
= new wxIEnumString
;
249 e
->ChangeCompleter(m_completer
);
256 DECLARE_IUNKNOWN_METHODS
;
259 // dtor doesn't have to be virtual as we're only ever deleted from our own
260 // Release() and are not meant to be derived form anyhow, but making it
261 // virtual silences gcc warnings; making it private makes it impossible to
262 // (mistakenly) delete us directly instead of calling Release()
263 virtual ~wxIEnumString()
265 ::DeleteCriticalSection(&m_csRestart
);
266 ::DeleteCriticalSection(&m_csCompleter
);
269 // Common part of all ctors.
272 ::InitializeCriticalSection(&m_csCompleter
);
273 ::InitializeCriticalSection(&m_csRestart
);
279 // Restart completions generation if needed. Should be only called from
280 // inside m_csCompleter.
282 // If false is returned, it means that there are no completions and that
283 // wxTextCompleter::GetNext() shouldn't be called at all.
284 bool RestartIfNeeded()
292 CSLock
lock(m_csRestart
);
298 } // Release m_csRestart before calling Start() to avoid blocking
299 // the main thread in UpdatePrefix() during its execution.
304 rc
= m_completer
->Start(prefix
);
311 // Critical section protecting m_completer itself. It must be entered when
312 // using the pointer to ensure that we don't continue using a dangling one
313 // after it is destroyed.
314 CRITICAL_SECTION m_csCompleter
;
316 // The completer we delegate to for the completions generation. It is never
317 // NULL after the initial ChangeCompleter() call.
318 wxTextCompleter
*m_completer
;
321 // Critical section m_prefix and m_restart. It should be only entered for
322 // short periods of time, i.e. we shouldn't call any wxTextCompleter
323 // methods from inside, to prevent the main thread from blocking on it in
325 CRITICAL_SECTION m_csRestart
;
327 // If m_restart is true, we need to call wxTextCompleter::Start() with the
328 // given prefix to restart generating the completions.
331 // Notice that we use LONG and not bool here to ensure that reading this
332 // value is atomic (32 bit reads are atomic operations under all Windows
333 // versions but reading bool isn't necessarily).
337 wxDECLARE_NO_COPY_CLASS(wxIEnumString
);
340 BEGIN_IID_TABLE(wxIEnumString
)
345 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumString
)
348 // This class gathers the all auto-complete-related stuff we use. It is
349 // allocated on demand by wxTextEntry when AutoComplete() is called.
350 class wxTextAutoCompleteData wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
353 // The constructor associates us with the given text entry.
354 wxTextAutoCompleteData(wxTextEntry
*entry
)
356 m_win(entry
->GetEditableWindow())
358 m_autoComplete
= NULL
;
359 m_autoCompleteDropDown
= NULL
;
360 m_enumStrings
= NULL
;
362 m_fixedCompleter
= NULL
;
363 m_customCompleter
= NULL
;
365 m_connectedCharEvent
= false;
367 // Create an object exposing IAutoComplete interface which we'll later
368 // use to get IAutoComplete2 as the latter can't be created directly,
370 HRESULT hr
= CoCreateInstance
372 wxCLSID_AutoComplete
,
374 CLSCTX_INPROC_SERVER
,
376 reinterpret_cast<void **>(&m_autoComplete
)
380 wxLogApiError(wxT("CoCreateInstance(CLSID_AutoComplete)"), hr
);
384 // Create a string enumerator and initialize the completer with it.
385 m_enumStrings
= new wxIEnumString
;
386 m_enumStrings
->AddRef();
387 hr
= m_autoComplete
->Init(m_entry
->GetEditHWND(), m_enumStrings
,
391 wxLogApiError(wxT("IAutoComplete::Init"), hr
);
393 m_enumStrings
->Release();
394 m_enumStrings
= NULL
;
399 // As explained in DoRefresh(), we need to call IAutoCompleteDropDown::
400 // ResetEnumerator() if we want to be able to change the completions on
401 // the fly. In principle we could live without it, i.e. return true
402 // from IsOk() even if this QueryInterface() fails, but it doesn't look
403 // like this is ever going to have in practice anyhow as the shell-
404 // provided IAutoComplete always implements IAutoCompleteDropDown too.
405 hr
= m_autoComplete
->QueryInterface
407 wxIID_IAutoCompleteDropDown
,
408 reinterpret_cast<void **>(&m_autoCompleteDropDown
)
412 wxLogApiError(wxT("IAutoComplete::QI(IAutoCompleteDropDown)"), hr
);
416 // Finally set the completion options using IAutoComplete2.
417 IAutoComplete2
*pAutoComplete2
= NULL
;
418 hr
= m_autoComplete
->QueryInterface
421 reinterpret_cast<void **>(&pAutoComplete2
)
425 pAutoComplete2
->SetOptions(ACO_AUTOSUGGEST
|
427 ACO_UPDOWNKEYDROPSLIST
);
428 pAutoComplete2
->Release();
432 ~wxTextAutoCompleteData()
434 delete m_customCompleter
;
435 delete m_fixedCompleter
;
438 m_enumStrings
->Release();
439 if ( m_autoCompleteDropDown
)
440 m_autoCompleteDropDown
->Release();
441 if ( m_autoComplete
)
442 m_autoComplete
->Release();
445 // Must be called after creating this object to verify if initializing it
449 return m_autoComplete
&& m_autoCompleteDropDown
&& m_enumStrings
;
452 void ChangeStrings(const wxArrayString
& strings
)
454 if ( !m_fixedCompleter
)
455 m_fixedCompleter
= new wxTextCompleterFixed
;
457 m_fixedCompleter
->SetCompletions(strings
);
459 m_enumStrings
->ChangeCompleter(m_fixedCompleter
);
464 // Takes ownership of the pointer if it is non-NULL.
465 bool ChangeCustomCompleter(wxTextCompleter
*completer
)
467 // Ensure that the old completer is not used any more before deleting
469 m_enumStrings
->ChangeCompleter(completer
);
471 delete m_customCompleter
;
472 m_customCompleter
= completer
;
474 if ( m_customCompleter
)
476 // We postpone connecting to this event until we really need to do
477 // it (however we don't disconnect from it when we don't need it
478 // any more because we don't have wxUNBIND_OR_DISCONNECT_HACK...).
479 if ( !m_connectedCharEvent
)
481 m_connectedCharEvent
= true;
483 // Use the special wxEVT_AFTER_CHAR and not the usual
484 // wxEVT_CHAR here because we need to have the updated value of
485 // the text control in this handler in order to provide
486 // completions for the correct prefix and unfortunately we
487 // don't have any way to let DefWindowProc() run from our
488 // wxEVT_CHAR handler (as we must also let the other handlers
489 // defined at wx level run first).
491 // Notice that we can't use wxEVT_COMMAND_TEXT_UPDATED here
492 // neither as, due to our use of ACO_AUTOAPPEND, we get
493 // EN_CHANGE notifications from the control every time
494 // IAutoComplete auto-appends something to it.
495 wxBIND_OR_CONNECT_HACK(m_win
, wxEVT_AFTER_CHAR
,
497 wxTextAutoCompleteData::OnAfterChar
,
501 UpdateStringsFromCustomCompleter();
507 void DisableCompletion()
509 // We currently simply reset the list of possible strings as this seems
510 // to effectively disable auto-completion just fine. We could (and
511 // probably should) use IAutoComplete::Enable(FALSE) for this too but
512 // then we'd need to call Enable(TRUE) to turn it on back again later.
513 ChangeStrings(wxArrayString());
517 // Must be called after changing the values to be returned by wxIEnumString
518 // to really make the changes stick.
521 m_enumStrings
->Reset();
523 // This is completely and utterly not documented and in fact the
524 // current MSDN seems to try to discourage us from using it by saying
525 // that "there is no reason to use this method unless the drop-down
526 // list is currently visible" but actually we absolutely must call it
527 // to force the auto-completer (and not just its drop-down!) to refresh
528 // the list of completions which could have changed now. Without this
529 // call the new choices returned by GetCompletions() that hadn't been
530 // returned by it before are simply silently ignored.
531 m_autoCompleteDropDown
->ResetEnumerator();
534 // Update the strings returned by our string enumerator to correspond to
535 // the currently valid choices according to the custom completer.
536 void UpdateStringsFromCustomCompleter()
538 // As we use ACO_AUTOAPPEND, the selected part of the text is usually
539 // the one appended by us so don't consider it as part of the
540 // user-entered prefix.
542 m_entry
->GetSelection(&from
, &to
);
545 from
= m_entry
->GetLastPosition(); // Take all if no selection.
547 const wxString prefix
= m_entry
->GetRange(0, from
);
549 m_enumStrings
->UpdatePrefix(prefix
);
554 void OnAfterChar(wxKeyEvent
& event
)
556 // Notice that we must not refresh the completions when the user
557 // presses Backspace as this would result in adding back the just
558 // erased character(s) because of ACO_AUTOAPPEND option we use.
559 if ( m_customCompleter
&& event
.GetKeyCode() != WXK_BACK
)
560 UpdateStringsFromCustomCompleter();
566 // The text entry we're associated with.
567 wxTextEntry
* const m_entry
;
569 // The window of this text entry.
570 wxWindow
* const m_win
;
572 // The auto-completer object itself.
573 IAutoComplete
*m_autoComplete
;
575 // Its IAutoCompleteDropDown interface needed for ResetEnumerator() call.
576 IAutoCompleteDropDown
*m_autoCompleteDropDown
;
578 // Enumerator for strings currently used for auto-completion.
579 wxIEnumString
*m_enumStrings
;
581 // Fixed string completer or NULL if none.
582 wxTextCompleterFixed
*m_fixedCompleter
;
584 // Custom completer or NULL if none.
585 wxTextCompleter
*m_customCompleter
;
587 // Initially false, set to true after connecting OnTextChanged() handler.
588 bool m_connectedCharEvent
;
591 wxDECLARE_NO_COPY_CLASS(wxTextAutoCompleteData
);
594 #endif // HAS_AUTOCOMPLETE
596 // ============================================================================
597 // wxTextEntry implementation
598 // ============================================================================
600 // ----------------------------------------------------------------------------
601 // initialization and destruction
602 // ----------------------------------------------------------------------------
604 wxTextEntry::wxTextEntry()
606 #ifdef HAS_AUTOCOMPLETE
607 m_autoCompleteData
= NULL
;
608 #endif // HAS_AUTOCOMPLETE
611 wxTextEntry::~wxTextEntry()
613 #ifdef HAS_AUTOCOMPLETE
614 delete m_autoCompleteData
;
615 #endif // HAS_AUTOCOMPLETE
618 // ----------------------------------------------------------------------------
619 // operations on text
620 // ----------------------------------------------------------------------------
622 void wxTextEntry::WriteText(const wxString
& text
)
624 ::SendMessage(GetEditHwnd(), EM_REPLACESEL
, 0, (LPARAM
)text
.wx_str());
627 wxString
wxTextEntry::DoGetValue() const
629 return wxGetWindowText(GetEditHWND());
632 void wxTextEntry::Remove(long from
, long to
)
634 DoSetSelection(from
, to
, SetSel_NoScroll
);
635 WriteText(wxString());
638 // ----------------------------------------------------------------------------
639 // clipboard operations
640 // ----------------------------------------------------------------------------
642 void wxTextEntry::Copy()
644 ::SendMessage(GetEditHwnd(), WM_COPY
, 0, 0);
647 void wxTextEntry::Cut()
649 ::SendMessage(GetEditHwnd(), WM_CUT
, 0, 0);
652 void wxTextEntry::Paste()
654 ::SendMessage(GetEditHwnd(), WM_PASTE
, 0, 0);
657 // ----------------------------------------------------------------------------
659 // ----------------------------------------------------------------------------
661 void wxTextEntry::Undo()
663 ::SendMessage(GetEditHwnd(), EM_UNDO
, 0, 0);
666 void wxTextEntry::Redo()
668 // same as Undo, since Undo undoes the undo
673 bool wxTextEntry::CanUndo() const
675 return ::SendMessage(GetEditHwnd(), EM_CANUNDO
, 0, 0) != 0;
678 bool wxTextEntry::CanRedo() const
680 // see comment in Redo()
684 // ----------------------------------------------------------------------------
685 // insertion point and selection
686 // ----------------------------------------------------------------------------
688 void wxTextEntry::SetInsertionPoint(long pos
)
690 // calling DoSetSelection(-1, -1) would select everything which is not what
693 pos
= GetLastPosition();
695 // be careful to call DoSetSelection() which is overridden in wxTextCtrl
696 // and not just SetSelection() here
697 DoSetSelection(pos
, pos
);
700 long wxTextEntry::GetInsertionPoint() const
703 GetSelection(&from
, NULL
);
707 long wxTextEntry::GetLastPosition() const
709 return ::SendMessage(GetEditHwnd(), EM_LINELENGTH
, 0, 0);
712 void wxTextEntry::DoSetSelection(long from
, long to
, int WXUNUSED(flags
))
714 // if from and to are both -1, it means (in wxWidgets) that all text should
715 // be selected, translate this into Windows convention
716 if ( (from
== -1) && (to
== -1) )
721 ::SendMessage(GetEditHwnd(), EM_SETSEL
, from
, to
);
724 void wxTextEntry::GetSelection(long *from
, long *to
) const
726 DWORD dwStart
, dwEnd
;
727 ::SendMessage(GetEditHwnd(), EM_GETSEL
, (WPARAM
)&dwStart
, (LPARAM
)&dwEnd
);
735 // ----------------------------------------------------------------------------
737 // ----------------------------------------------------------------------------
741 #ifdef HAS_AUTOCOMPLETE
743 bool wxTextEntry::DoAutoCompleteFileNames()
745 typedef HRESULT (WINAPI
*SHAutoComplete_t
)(HWND
, DWORD
);
746 static SHAutoComplete_t s_pfnSHAutoComplete
= (SHAutoComplete_t
)-1;
747 static wxDynamicLibrary s_dllShlwapi
;
748 if ( s_pfnSHAutoComplete
== (SHAutoComplete_t
)-1 )
750 if ( !s_dllShlwapi
.Load(wxT("shlwapi.dll"), wxDL_VERBATIM
| wxDL_QUIET
) )
752 s_pfnSHAutoComplete
= NULL
;
756 wxDL_INIT_FUNC(s_pfn
, SHAutoComplete
, s_dllShlwapi
);
760 if ( !s_pfnSHAutoComplete
)
763 HRESULT hr
= (*s_pfnSHAutoComplete
)(GetEditHwnd(), SHACF_FILESYS_ONLY
);
766 wxLogApiError(wxT("SHAutoComplete()"), hr
);
771 // Disable the other kinds of completion now that we use the built-in file
773 if ( m_autoCompleteData
)
774 m_autoCompleteData
->DisableCompletion();
779 wxTextAutoCompleteData
*wxTextEntry::GetOrCreateCompleter()
781 if ( !m_autoCompleteData
)
783 wxTextAutoCompleteData
* const ac
= new wxTextAutoCompleteData(this);
785 m_autoCompleteData
= ac
;
790 return m_autoCompleteData
;
793 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
795 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
799 ac
->ChangeStrings(choices
);
804 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
806 // First deal with the case when we just want to disable auto-completion.
809 if ( m_autoCompleteData
)
810 m_autoCompleteData
->DisableCompletion();
811 //else: Nothing to do, we hadn't used auto-completion even before.
813 else // Have a valid completer.
815 wxTextAutoCompleteData
* const ac
= GetOrCreateCompleter();
818 // Delete the custom completer for consistency with the case when
819 // we succeed to avoid memory leaks in user code.
824 // This gives ownership of the custom completer to m_autoCompleteData.
825 if ( !ac
->ChangeCustomCompleter(completer
) )
832 #else // !HAS_AUTOCOMPLETE
834 // We still need to define stubs as we declared these overrides in the header.
836 bool wxTextEntry::DoAutoCompleteFileNames()
838 return wxTextEntryBase::DoAutoCompleteFileNames();
841 bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString
& choices
)
843 return wxTextEntryBase::DoAutoCompleteStrings(choices
);
846 bool wxTextEntry::DoAutoCompleteCustom(wxTextCompleter
*completer
)
848 return wxTextEntryBase::DoAutoCompleteCustom(completer
);
851 #endif // HAS_AUTOCOMPLETE/!HAS_AUTOCOMPLETE
855 // ----------------------------------------------------------------------------
857 // ----------------------------------------------------------------------------
859 bool wxTextEntry::IsEditable() const
861 return !(::GetWindowLong(GetEditHwnd(), GWL_STYLE
) & ES_READONLY
);
864 void wxTextEntry::SetEditable(bool editable
)
866 ::SendMessage(GetEditHwnd(), EM_SETREADONLY
, !editable
, 0);
869 // ----------------------------------------------------------------------------
871 // ----------------------------------------------------------------------------
873 void wxTextEntry::SetMaxLength(unsigned long len
)
877 // this will set it to a platform-dependent maximum (much more
878 // than 64Kb under NT)
882 ::SendMessage(GetEditHwnd(), EM_LIMITTEXT
, len
, 0);
885 // ----------------------------------------------------------------------------
887 // ----------------------------------------------------------------------------
891 #ifndef EM_SETCUEBANNER
892 #define EM_SETCUEBANNER 0x1501
893 #define EM_GETCUEBANNER 0x1502
896 bool wxTextEntry::SetHint(const wxString
& hint
)
898 if ( wxUxThemeEngine::GetIfActive() )
900 // notice that this message always works with Unicode strings
902 // we always use TRUE for wParam to show the hint even when the window
903 // has focus, otherwise there would be no way to show the hint for the
904 // initially focused window
905 if ( ::SendMessage(GetEditHwnd(), EM_SETCUEBANNER
,
906 TRUE
, (LPARAM
)(const wchar_t *)hint
.wc_str()) )
910 return wxTextEntryBase::SetHint(hint
);
913 wxString
wxTextEntry::GetHint() const
915 if ( wxUxThemeEngine::GetIfActive() )
918 if ( ::SendMessage(GetEditHwnd(), EM_GETCUEBANNER
,
919 (WPARAM
)buf
, WXSIZEOF(buf
)) )
920 return wxString(buf
);
923 return wxTextEntryBase::GetHint();
927 #endif // wxUSE_UXTHEME
929 // ----------------------------------------------------------------------------
931 // ----------------------------------------------------------------------------
933 bool wxTextEntry::DoSetMargins(const wxPoint
& margins
)
935 #if !defined(__WXWINCE__)
938 if ( margins
.x
!= -1 )
941 ::SendMessage(GetEditHwnd(), EM_SETMARGINS
,
942 EC_LEFTMARGIN
, MAKELONG(margins
.x
, 0));
945 if ( margins
.y
!= -1 )
956 wxPoint
wxTextEntry::DoGetMargins() const
958 #if !defined(__WXWINCE__)
959 LRESULT lResult
= ::SendMessage(GetEditHwnd(), EM_GETMARGINS
,
961 int left
= LOWORD(lResult
);
963 return wxPoint(left
, top
);
965 return wxPoint(-1, -1);
969 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX