]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
Fix potential crash, fixes #12375: PATCH to fix help controller crash
[wxWidgets.git] / src / msw / textctrl.cpp
index d5e40992c3183f0764356e7e6cda7de356993b6d..c2417d2cc4aedd24a83bfb228699968be94025ef 100644 (file)
@@ -1193,9 +1193,7 @@ void wxTextCtrl::AppendText(const wxString& text)
     // don't do this if we're frozen, saves some time
     if ( !IsFrozen() && IsMultiLine() && GetRichVersion() > 1 )
     {
     // don't do this if we're frozen, saves some time
     if ( !IsFrozen() && IsMultiLine() && GetRichVersion() > 1 )
     {
-        // setting the caret to the end and showing it simply doesn't work for
-        // RichEdit 2.0 -- force it to still do what we want
-        ::SendMessage(GetHwnd(), EM_LINESCROLL, 0, GetNumberOfLines());
+        ::SendMessage(GetHwnd(), WM_VSCROLL, SB_BOTTOM, NULL);
     }
 #endif // wxUSE_RICHEDIT
 }
     }
 #endif // wxUSE_RICHEDIT
 }
@@ -2360,6 +2358,26 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
     return true;
 }
 
     return true;
 }
 
+bool wxTextCtrl::SetFont(const wxFont& font)
+{
+    if ( !wxTextCtrlBase::SetFont(font) )
+        return false;
+
+    if ( IsRich() )
+    {
+        // Using WM_SETFONT doesn't work reliably with rich edit controls: as
+        // an example, if we set a fixed width font for a richedit 4.1 control,
+        // it's used for the ASCII characters but inserting any non-ASCII ones
+        // switches the font to a proportional one, whether it's done
+        // programmatically or not. So just use EM_SETCHARFORMAT for this too.
+        wxTextAttr attr;
+        attr.SetFont(font);
+        SetDefaultStyle(attr);
+    }
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 // styling support for rich edit controls
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // styling support for rich edit controls
 // ----------------------------------------------------------------------------