Commit acfb6ea2 authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

richedit: Do not read actual scrollbar state for scrollbar update, use internal state instead.

parent 9d39754e
......@@ -1807,6 +1807,13 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
/* Default vertical scrollbar information */
ed->vert_si.cbSize = sizeof(SCROLLINFO);
ed->vert_si.nMin = 0;
ed->vert_si.nMax = 0;
ed->vert_si.nPage = 0;
ed->vert_si.nPos = 0;
return ed;
}
......@@ -3055,15 +3062,29 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
}
case WM_CREATE:
{
SCROLLINFO si;
GetClientRect(hWnd, &editor->rcFormat);
if (GetWindowLongW(hWnd, GWL_STYLE) & WS_HSCROLL)
{ /* Squelch the default horizontal scrollbar it would make */
ShowScrollBar(editor->hWnd, SB_HORZ, FALSE);
}
si.cbSize = sizeof(si);
si.fMask = SIF_PAGE | SIF_RANGE;
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
si.fMask |= SIF_DISABLENOSCROLL;
si.nMax = (si.fMask & SIF_DISABLENOSCROLL) ? 1 : 0;
si.nMin = 0;
si.nPage = 0;
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
ME_CommitUndo(editor);
ME_WrapMarkedParagraphs(editor);
ME_MoveCaret(editor);
return 0;
}
case WM_DESTROY:
ME_DestroyEditor(editor);
SetWindowLongPtrW(hWnd, 0, 0);
......
......@@ -343,6 +343,9 @@ typedef struct tagME_TextEditor
/* Track previous notified selection */
CHARRANGE notified_cr;
/* Cache previously set vertical scrollbar info */
SCROLLINFO vert_si;
} ME_TextEditor;
typedef struct tagME_Context
......
......@@ -784,6 +784,7 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
ME_Repaint(editor);
}
editor->vert_si.nMax = 0;
ME_UpdateScrollBar(editor);
}
......@@ -806,6 +807,14 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
bScrollBarWasVisible = ME_GetYScrollVisible(editor);
bScrollBarWillBeVisible = editor->nHeight > editor->sizeWindow.cy;
si.fMask = SIF_PAGE | SIF_RANGE;
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
si.fMask |= SIF_DISABLENOSCROLL;
if ((si.fMask & SIF_DISABLENOSCROLL))
{
bScrollBarWillBeVisible = TRUE;
}
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
{
ShowScrollBar(hWnd, SB_VERT, bScrollBarWillBeVisible);
......@@ -813,17 +822,27 @@ void ME_Scroll(ME_TextEditor *editor, int value, int type)
ME_WrapMarkedParagraphs(editor);
}
si.fMask = SIF_PAGE | SIF_RANGE;
if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL)
si.fMask |= SIF_DISABLENOSCROLL;
si.nMin = 0;
si.nMax = editor->nTotalLength;
si.nPage = editor->sizeWindow.cy;
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
if (!(si.nMin == editor->vert_si.nMin && si.nMax == editor->vert_si.nMax && si.nPage == editor->vert_si.nPage))
{
TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
editor->vert_si.nMin = si.nMin;
editor->vert_si.nMax = si.nMax;
editor->vert_si.nPage = si.nPage;
if (bScrollBarWillBeVisible)
{
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
}
else
{
if (bScrollBarWasVisible && !(si.fMask & SIF_DISABLENOSCROLL))
ShowScrollBar(hWnd, SB_VERT, FALSE);
}
}
}
int ME_GetYScrollPos(ME_TextEditor *editor)
......@@ -836,10 +855,7 @@ int ME_GetYScrollPos(ME_TextEditor *editor)
BOOL ME_GetYScrollVisible(ME_TextEditor *editor)
{ /* Returns true if the scrollbar is visible */
SCROLLBARINFO sbi;
sbi.cbSize = sizeof(sbi);
GetScrollBarInfo(editor->hWnd, OBJID_VSCROLL, &sbi);
return ((sbi.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0);
return (editor->vert_si.nMax - editor->vert_si.nMin >= max(editor->vert_si.nPage - 1, 0));
}
void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment