LCL: improved logic to retrieve WheelScrollLines.

win32 widget set: use Mouse.WheelScrollLines to determine the mouse wheel scroll lines.

git-svn-id: trunk@15717 -
This commit is contained in:
vincents 2008-07-09 09:07:53 +00:00
parent fa17781d1d
commit 97c1684037
2 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,6 @@
constructor TMouse.Create;
begin
inherited Create;
FWheelScrollLines := -1;
end;
destructor TMouse.destroy;
@ -61,9 +60,10 @@ end;
function TMouse.GetWheelScrollLines: Integer;
begin
if FWheelScrollLines = -1 then
if FWheelScrollLines = 0 then
begin
WidgetSet.SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @FWheelScrollLines, 0);
if not WidgetSet.SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @FWheelScrollLines, 0) then
FWheelScrollLines := 3;
end;
Result := FWheelScrollLines;
end;

View File

@ -173,7 +173,6 @@ var
FillChar(ScrollInfo, sizeof(ScrollInfo), #0);
ScrollInfo.cbSize := sizeof(ScrollInfo);
ScrollInfo.fMask := SIF_PAGE or SIF_POS or SIF_RANGE;
WParam := (TLMMouseEvent(Message).X and $FFFF) or (longint(TLMMouseEvent(Message).Y and $FFFF) shl 16);
// if mouse is over horizontal scrollbar, scroll horizontally
if Windows.SendMessage(Handle, WM_NCHITTEST, 0, WParam) = HTHSCROLL then
begin
@ -187,10 +186,11 @@ var
begin
with TLMMouseEvent(Message) do
begin
if SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(WheelScrollLines), @WheelScrollLines, 0) then
ScrollOffset := (WheelDelta * WheelScrollLines) div 120
else // no system parameter, scroll 1/8 page
ScrollOffset := (WheelDelta * Integer(ScrollInfo.nPage)) div (120 * 8);
if Mouse.WheelScrollLines=-1 then
// -1 means, scroll one page
ScrollOffset := (WheelDelta * ScrollInfo.nPage) div 120
else
ScrollOffset := (WheelDelta * Mouse.WheelScrollLines) div 120;
WParam := Windows.WParam(ScrollInfo.nPos - ScrollOffset);
if WParam > ScrollInfo.nMax - integer(ScrollInfo.nPage) + 1 then
WParam := ScrollInfo.nMax - integer(ScrollInfo.nPage) + 1;