[1/2] richedit: Initially disable scrollbars for ES_DISABLENOSCROLL.

Dylan Smith dylan.ah.smith at gmail.com
Thu Jul 16 17:45:59 CDT 2009


Previously after initial window creation of a richedit control with the
ES_DISABLENOSCROLL window style flag the scrollbar would be shown but
not disabled.  This patch fixes this issue by explicitly disabling and
showing the scrollbar.

Previously SetScrollInfo was relied upon to disable the scrollbar, but I
found the initial state of the disabled scrollbar is not suitable for
causing it to be disabled in this way (e.g. page=0 min=0 max=1).  In
some cases the scrollbar is not even initialized (detectable by the return
value of GetScrollInfo).

I wrote tests to determine the proper initial state of the scrollbar
depending on what flags are used on CreateWindow, but there are bugs in
the user32 that were causing failures that were unrelated to richedit
controls (see todo statements in user32/tests/scroll.c). Instead I
tested using a native riched20 overrides, instead of running the
crosstests on windows to make sure my implementation was correct.
(The tests attached to Bug 18214)
---
 dlls/riched20/editor.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 4cd72c8..7ffb7cb 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3842,23 +3842,29 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
   }
   case WM_CREATE:
   {
-    SCROLLINFO si;
+    INT max;
 
     ME_SetDefaultFormatRect(editor);
 
-    si.cbSize = sizeof(si);
-    si.fMask = SIF_PAGE | SIF_RANGE;
+    max = (editor->styleFlags & ES_DISABLENOSCROLL) ? 1 : 0;
+    if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_VSCROLL)
+      ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, 0, max, TRUE);
+
+    if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_HSCROLL)
+      ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, 0, max, TRUE);
+
     if (editor->styleFlags & ES_DISABLENOSCROLL)
-      si.fMask |= SIF_DISABLENOSCROLL;
-    si.nMax = (si.fMask & SIF_DISABLENOSCROLL) ? 1 : 0;
-    si.nMin = 0;
-    si.nPage = 0;
-    if (editor->hWnd) {
-      SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
-      SetScrollInfo(editor->hWnd, SB_HORZ, &si, TRUE);
-    } else {
-      ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, si.nMin, si.nMax, TRUE);
-      ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, si.nMin, si.nMax, TRUE);
+    {
+      if (editor->styleFlags & WS_VSCROLL)
+      {
+        ITextHost_TxEnableScrollBar(editor->texthost, SB_VERT, ESB_DISABLE_BOTH);
+        ITextHost_TxShowScrollBar(editor->texthost, SB_VERT, TRUE);
+      }
+      if (editor->styleFlags & WS_HSCROLL)
+      {
+        ITextHost_TxEnableScrollBar(editor->texthost, SB_HORZ, ESB_DISABLE_BOTH);
+        ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, TRUE);
+      }
     }
 
     ME_CommitUndo(editor);


More information about the wine-patches mailing list