From 84d5992357decd85557e905fb1574b4ce4e57e9e Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 11 Aug 2003 18:41:52 +0000 Subject: [PATCH] Make sure winhelp doesn't scroll outside of its display area. --- programs/winhelp/winhelp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c index 623f8741658..6494d872cf1 100644 --- a/programs/winhelp/winhelp.c +++ b/programs/winhelp/winhelp.c @@ -814,6 +814,8 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam, RECT rect; INT Min, Max; INT CurPos = GetScrollPos(hWnd, SB_VERT); + INT dy; + GetScrollRange(hWnd, SB_VERT, &Min, &Max); GetClientRect(hWnd, &rect); @@ -831,7 +833,11 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam, } if (update) { - INT dy = GetScrollPos(hWnd, SB_VERT) - CurPos; + if (CurPos > Max) + CurPos = Max; + else if (CurPos < Min) + CurPos = Min; + dy = GetScrollPos(hWnd, SB_VERT) - CurPos; SetScrollPos(hWnd, SB_VERT, CurPos, TRUE); ScrollWindow(hWnd, 0, dy, NULL, NULL); UpdateWindow(hWnd);