From b406377da2bc5096e49d823cb66a332022e679b1 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Mon, 22 Mar 2021 08:55:52 +0000 Subject: [PATCH] riched20: Enable and show the scrollbar before updating its position and range. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/riched20/paint.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index c9e2fab0be6..0b29aba4f9f 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1033,6 +1033,14 @@ static void draw_paragraph( ME_Context *c, ME_Paragraph *para ) SetTextAlign( c->hDC, align ); } +static void enable_show_scrollbar( ME_TextEditor *editor, INT bar, BOOL enable ) +{ + if (enable || editor->scrollbars & ES_DISABLENOSCROLL) + ITextHost_TxEnableScrollBar( editor->texthost, bar, enable ? 0 : ESB_DISABLE_BOTH ); + if (!(editor->scrollbars & ES_DISABLENOSCROLL)) + ITextHost_TxShowScrollBar( editor->texthost, bar, enable ); +} + static void set_scroll_range_pos( ITextHost *host, INT bar, SCROLLINFO *info, BOOL set_range ) { LONG max_pos = info->nMax, pos = info->nPos; @@ -1145,6 +1153,12 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) return; } + if (editor->scrollbars & WS_HSCROLL && !enable ^ !editor->horz_sb_enabled) + { + editor->horz_sb_enabled = enable; + enable_show_scrollbar( editor, SB_HORZ, enable ); + } + if (editor->horz_si.nMax != editor->nTotalWidth || editor->horz_si.nPage != editor->sizeWindow.cx) { editor->horz_si.nMax = editor->nTotalWidth; @@ -1154,15 +1168,6 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) set_scroll_range_pos( editor->texthost, SB_HORZ, &editor->horz_si, TRUE ); } - if (editor->scrollbars & WS_HSCROLL && !enable ^ !editor->horz_sb_enabled) - { - if (enable || editor->scrollbars & ES_DISABLENOSCROLL) - ITextHost_TxEnableScrollBar( editor->texthost, SB_HORZ, enable ? 0 : ESB_DISABLE_BOTH ); - if (!(editor->scrollbars & ES_DISABLENOSCROLL)) - ITextHost_TxShowScrollBar( editor->texthost, SB_HORZ, enable ); - editor->horz_sb_enabled = enable; - } - /* Update vertical scrollbar */ enable = editor->nTotalLength > editor->sizeWindow.cy && (editor->props & TXTBIT_MULTILINE); @@ -1173,6 +1178,12 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) return; } + if (editor->scrollbars & WS_VSCROLL && !enable ^ !editor->vert_sb_enabled) + { + editor->vert_sb_enabled = enable; + enable_show_scrollbar( editor, SB_VERT, enable ); + } + if (editor->vert_si.nMax != editor->nTotalLength || editor->vert_si.nPage != editor->sizeWindow.cy) { editor->vert_si.nMax = editor->nTotalLength; @@ -1181,15 +1192,6 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) if ((enable || editor->vert_sb_enabled) && editor->scrollbars & WS_VSCROLL) set_scroll_range_pos( editor->texthost, SB_VERT, &editor->vert_si, TRUE ); } - - if (editor->scrollbars & WS_VSCROLL && !enable ^ !editor->vert_sb_enabled) - { - if (enable || editor->scrollbars & ES_DISABLENOSCROLL) - ITextHost_TxEnableScrollBar( editor->texthost, SB_VERT, enable ? 0 : ESB_DISABLE_BOTH ); - if (!(editor->scrollbars & ES_DISABLENOSCROLL)) - ITextHost_TxShowScrollBar( editor->texthost, SB_VERT, enable ); - editor->vert_sb_enabled = enable; - } } void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor )