X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a1b82138efe9aacda4e0ad7ce4b1551d624524c4..7309b92dd71901b8c96dea3e48e57a6c21d072a4:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 0a3471b403..6770cc598c 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -57,7 +57,7 @@ # include #endif -#if wxUSE_RICHEDIT && !defined(__GNUWIN32__) +#if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS)) #include #endif @@ -112,7 +112,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& name) { // base initialization - if ( !CreateBase(parent, id, pos, size, style, name) ) + if ( !CreateBase(parent, id, pos, size, style, validator, name) ) return FALSE; SetValidator(validator); @@ -164,10 +164,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxChar *windowClass = _T("EDIT"); #if wxUSE_RICHEDIT - // multiline edit controls are RICHEDITs except for those which have a - // simple border (VZ: why??) - if ( (m_windowStyle & wxTE_MULTILINE) && - !(m_windowStyle & wxSIMPLE_BORDER) ) + if ( m_windowStyle & wxTE_RICH ) { msStyle |= ES_AUTOVSCROLL; m_isRich = TRUE; @@ -603,17 +600,41 @@ long wxTextCtrl::XYToPosition(long x, long y) const return (long)(x + charIndex); } -void wxTextCtrl::PositionToXY(long pos, long *x, long *y) const +bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const { HWND hWnd = GetHwnd(); // This gets the line number containing the character - int lineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, (LPARAM)0); + int lineNo; +#if wxUSE_RICHEDIT + if ( m_isRich ) + { + lineNo = (int)SendMessage(hWnd, EM_EXLINEFROMCHAR, 0, (LPARAM)pos); + } + else +#endif // wxUSE_RICHEDIT + lineNo = (int)SendMessage(hWnd, EM_LINEFROMCHAR, (WPARAM)pos, 0); + + if ( lineNo == -1 ) + { + // no such line + return FALSE; + } + // This gets the char index for the _beginning_ of this line int charIndex = (int)SendMessage(hWnd, EM_LINEINDEX, (WPARAM)lineNo, (LPARAM)0); + if ( charIndex == -1 ) + { + return FALSE; + } + // The X position must therefore be the different between pos and charIndex - *x = (long)(pos - charIndex); - *y = (long)lineNo; + if ( x ) + *x = (long)(pos - charIndex); + if ( y ) + *y = (long)lineNo; + + return TRUE; } void wxTextCtrl::ShowPosition(long pos)