Mouse wheel scroll settings

  • Scrolling a WPRichText using the mouse wheel does not appear to honor Window 10's Mouse Wheel line scrolling setting of "choose how many lines to scroll each time" like other editors such as Word does. Is this by design or am I missing something?

    Thanks.

  • I would like to revisit this because I am getting a lot of complaints about how sluggish the scrolling appears in our new version which uses WPT9 vs our old version which uses WPT5. I am not sure what is going on, but on some computers, when at 140% zoom a single mouse wheel tick moves the text only about one line at a time with WPT9, whereas on WPT5 it moves it about 3.5 lines.

    So it would be huge if you could somehow factor in the mouse wheel scroll lines setting in Windows even if you have it conditionally compiled in for newer versions of Delphi. In Delphi, you use Mouse,WheelScrollLines (part of Vcl.Controls) to get the number of lines to move for each wheel click. https://docwiki.embarcadero.com/Libraries/Sydn…heelScrollLines

    I looked for WM_MOUSEWHEEL in your code, but only found one place and it was in an IF statement where it was checking for not equal. So I don't know how or where you are handling the mouse wheel (was trying to help out). Even if I have to customize the code on my end I'm fine with that... just needs to be better handled if at all possible.

    Looks like DoMouseWheelDown function in WPCTRMemo is invoked on a wheel scroll event. Just don't know yet what affects the lines to scroll.

    I modified the lines in DoMouseWheelDown and DoMouseWheelUp like this, respectively:

    Code
    FMemo.TopOffset := FMemo.TopOffset + Round(72 / CurrentZooming * 100) * Mouse.WheelScrollLines;
    and
    FMemo.TopOffset := FMemo.TopOffset - Round(72 / CurrentZooming * 100) * Mouse.WheelScrollLines;

    Boy, a difference that makes! :) I'll play with that and will let you know how it all turns out!

    Thanks

    2 Mal editiert, zuletzt von ehimmer (8. Februar 2022 um 13:42)

  • I settled on this. I didn't quite understand why your equation reduced the scroll amount when the zoom is higher but I think it should really increase it, so I reversed that part of it.

    For DoMouseWheelDown:

    Code
        if (GetAsyncKeyState(VK_SHIFT) < 0) then
          FMemo.TopOffset := FMemo.TopOffset + Round(WPScreenPixelsPerInch / 6 * 2 * Mouse.WheelScrollLines / 100 * CurrentZooming)
        else
          FMemo.TopOffset := FMemo.TopOffset + Round(WPScreenPixelsPerInch / 6 * Mouse.WheelScrollLines / 100 * CurrentZooming);

    For DoMouseWheelUp:

    Code
        if (GetAsyncKeyState(VK_SHIFT) < 0) then
          FMemo.TopOffset := FMemo.TopOffset - Round(WPScreenPixelsPerInch / 6 * 2 * Mouse.WheelScrollLines / 100 * CurrentZooming)
        else
          FMemo.TopOffset := FMemo.TopOffset - Round(WPScreenPixelsPerInch / 6 * Mouse.WheelScrollLines / 100 * CurrentZooming);

    I chose WPScreenPixelsPerInch instead of the hard coded 72 in case a user's pixels per inch was not 72 (mine is 96). I then divided by 6 because a typical document is 6 lines per inch at 10pt font (not critical, just needed a consistent reference for a typical height of a single line). Then multiplied by the Windows setting for scroll lines per wheel tick. I then compensated for the current zoom so that it increases as the zoom increases (and decreases as the zoom decreases) rather than decreasing it as the zoom increases like you had.

    Hope this seems good.

    Eric