} ENLINK;
#endif // ENLINK
+#ifndef SF_UNICODE
+ #define SF_UNICODE 0x0010
+#endif
+
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
Clear();
WriteText(value);
+
+ // mark the control as being not dirty - we changed its text, not the
+ // user
+ DiscardEdits();
+
+ // for compatibility, don't move the cursor when doing SetValue()
+ SetInsertionPoint(0);
}
}
-#if wxUSE_RICHEDIT
+#if wxUSE_RICHEDIT && !wxUSE_UNICODE
DWORD CALLBACK wxRichEditStreamIn(DWORD dwCookie, BYTE *buf, LONG cb, LONG *pcb)
{
EDITSTREAM eds;
wxZeroMemory(eds);
eds.dwCookie = (DWORD)&wpc;
- eds.pfnCallback = wxRichEditStreamIn;
+ // the cast below is needed for broken (very) old mingw32 headers
+ eds.pfnCallback = (EDITSTREAMCALLBACK)wxRichEditStreamIn;
if ( !::SendMessage(GetHwnd(), EM_STREAMIN,
SF_TEXT | SF_UNICODE | SFF_SELECTION,
SetStyle(start, end, m_defaultStyle );
}
+#if !wxUSE_UNICODE
// next check if the text we're inserting must be shown in a non
// default charset -- this only works for RichEdit > 1.0
if ( GetRichVersion() > 1 )
}
}
}
+#endif // !wxUSE_UNICODE
}
if ( !done )
void wxTextCtrl::SetInsertionPoint(long pos)
{
SetSelection(pos, pos);
-
-#if wxUSE_RICHEDIT
- if ( !IsRich() )
-#endif
- {
- static const wxChar *nothing = _T("");
- SendMessage(GetHwnd(), EM_REPLACESEL, 0, (LPARAM)nothing);
- }
}
void wxTextCtrl::SetInsertionPointEnd()
if ( scrollCaret )
{
+#if wxUSE_RICHEDIT
+ // EM_SCROLLCARET doesn't work for me with the richedit controls
+ // unless it has focus although I don't see any mention of it in the
+ // docs - this is the only workaround I found. Of course it's not
+ // perfect as it adds the dummy focus set/kill events but it's still
+ // better than nothing
+ HWND hwndFocusOld;
+ if ( IsRich() )
+ {
+ hwndFocusOld = ::GetFocus();
+ if ( hwndFocusOld == GetHwnd() )
+ {
+ // don't change focus
+ hwndFocusOld = 0;
+ }
+
+ if ( hwndFocusOld )
+ {
+ ::SetFocus(GetHwnd());
+ }
+ }
+ else // not rich
+ {
+ hwndFocusOld = 0;
+ }
+#endif // wxUSE_RICHEDIT
+
SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
+
+#if wxUSE_RICHEDIT
+ if ( hwndFocusOld )
+ {
+ ::SetFocus(hwndFocusOld);
+ }
+#endif // wxUSE_RICHEDIT
}
#else // Win16
// WPARAM is 0: selection is scrolled into view
void wxTextCtrl::Replace(long from, long to, const wxString& value)
{
// Set selection and remove it
- DoSetSelection(from, to, FALSE);
+ DoSetSelection(from, to, FALSE /* don't scroll caret into view */);
SendMessage(GetHwnd(), EM_REPLACESEL,
#ifdef __WIN32__
if ( changeSel )
{
- DoSetSelection(start, end, FALSE);
+ DoSetSelection(start, end, FALSE /* don't scroll caret into view */);
}
// initialize CHARFORMAT struct