X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6a277032d99841a845192cddd62a2c6810122f2..07aaf32633ecf18ec3edfbb41793a112914792d0:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 9fa201a931..930b37cd6d 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -229,7 +229,7 @@ void wxTextCtrl::Init() m_isNativeCaretShown = true; } -wxTextCtrl::~wxTextCtrl() wxNOEXCEPT +wxTextCtrl::~wxTextCtrl() { #if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT if ( m_dropTarget == wxRICHTEXT_DEFAULT_DROPTARGET ) @@ -499,7 +499,37 @@ bool wxTextCtrl::MSWCreateText(const wxString& value, SetWindowPos(GetHwnd(), NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE| SWP_FRAMECHANGED); -#endif + + if ( IsSingleLine() ) + { + // If we don't set the margins explicitly, their size depends on the + // control initial size, see #2438. So explicitly set them to something + // consistent. And for this we have 2 candidates: EC_USEFONTINFO (which + // sets the left margin to 3 pixels, at least under Windows 7) or 0. We + // use the former because it looks like it was meant to be used as the + // default (what else would it be there for?) and 0 looks bad in + // classic mode, i.e. without themes. Also, the margin can be reset to + // 0 easily by calling SetMargins() explicitly but setting it to the + // default value is not currently supported. + // + // Finally, notice that EC_USEFONTINFO is used differently for plain + // and rich text controls. + WPARAM wParam; + LPARAM lParam; + if ( IsRich() ) + { + wParam = EC_USEFONTINFO; + lParam = 0; + } + else // plain EDIT, EC_USEFONTINFO is used in lParam with them. + { + wParam = EC_LEFTMARGIN | EC_RIGHTMARGIN; + lParam = MAKELPARAM(EC_USEFONTINFO, EC_USEFONTINFO); + } + + ::SendMessage(GetHwnd(), EM_SETMARGINS, wParam, lParam); + } +#endif // !__WXWINCE__ return true; } @@ -993,7 +1023,7 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const EDITSTREAM eds; wxZeroMemory(eds); - eds.dwCookie = (DWORD)&data; + eds.dwCookie = (DWORD_PTR)&data; eds.pfnCallback = wxRichEditStreamOut; ::SendMessage