question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll wheel zoom works on Win10 but not Win7

See original GitHub issue

Bug description: Scroll wheel zoom not working in WinForms, enableScrollWheelZoom is set to true.

Steps to reproduce:

  1. Drag and drop a formsPlot into the designer.
  2. Enable the scroll with zoom using formsPlot1.Configure(enableScrollWheelZoom: true);
  3. Start the program and try to zoom using the scroll wheel

Additional info: Everything else works as expected. You can zoom using right click. Using .Configure works on other settings properly. MouseWheel event is working properly. Everything works fine in the WPF version, this is a problem with the WinForms version. I’m using the 2017 version of Visual Studio with the latest version of ScottPlot on NuGet (4.0.29).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
swhardencommented, Nov 29, 2020

I couldn’t leave that stack overflow code block alone though 😅

Here’s a more straightforward version

/// <summary>
/// Return the version and name of the Windows operating system in use
/// </summary>
public static (decimal version, string name) GetOsInfo()
{
    // Derived from https://stackoverflow.com/questions/2819934/detect-windows-version-in-net
    int minorVersion = Environment.OSVersion.Version.Minor;
    int majorVersion = Environment.OSVersion.Version.Major;

    if (minorVersion == 0)
        return (0, "Windows 95");
    if (minorVersion == 10)
        return (2, "Windows 98");
    if (minorVersion == 90)
        return (3, "Windows ME");
    if (majorVersion == 3)
        return ((decimal)3.51, "Windows NT3");
    if (majorVersion == 4)
        return ((decimal)4.0, "Windows NT4");
    if (majorVersion == 5 && minorVersion == 0)
        return ((decimal)5.0, "Windows 2000");
    if (majorVersion == 5)
        return ((decimal)5.1, "Windows XP");
    if (majorVersion == 6 && minorVersion == 0)
        return (6, "Windows Vista");
    if (majorVersion == 6 && minorVersion == 1)
        return (7, "Windows 7");
    if (majorVersion == 6 && minorVersion == 2)
        return (8, "Windows 8");
    if (majorVersion == 6)
        return ((decimal)8.1, "Windows 8.1");
    if (majorVersion == 10)
        return (10, "Windows 10");

    throw new InvalidOperationException("Unknown Windows Version");
}
1reaction
swhardencommented, Nov 29, 2020

Thanks @vrdriver! I cleaned it up a bit and will leave it here for future people who may search for this similar question. I’m happy to hear you found a solution that works for you!

public void formsPlot2_MouseWheel(object sender, MouseEventArgs e)
{
    // Windows 7 and earlier need this to support scroll wheel zooming
    if (Environment.OSVersion.Version.Major <= 7)
    {
        formsPlot2.Focus();
        double xFrac = (e.Delta > 0) ? 1.15 : 0.85;
        double yFrac = (e.Delta > 0) ? 1.15 : 0.85;
        double zoomToX = formsPlot2.plt.CoordinateFromPixelX(e.Location.X);
        double zoomToY = formsPlot2.plt.CoordinateFromPixelY(e.Location.Y);
        formsPlot2.plt.AxisZoom(xFrac, yFrac, zoomToX, zoomToY);
        formsPlot2.Render();
        formsPlot2.Focus();
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll wheel zoom works on Win10 but not Win7 · Issue #354
Scroll wheel zoom not working in WinForms, enableScrollWheelZoom is set to true. Steps to reproduce: Drag and drop a formsPlot into the designer ......
Read more >
How to Fix Mouse Zooming Instead of Scrolling on Windows?
If it doesn't work, the only way to stop the annoying zooming behavior of your mouse is to replace your keyboard.
Read more >
Mouse Wheel Zooms In and Out Instead of Scrolling
On the right-hand pane, uncheck the box associated with the option Zoom on roll with Intellimouse. Click on OK to save the changes...
Read more >
Mouse wheel not working only in browsers on Win 10
However, zooming in/out with mouse wheel works fine even in browsers. I use Windows 10, Logitech Options, everything is up-to-date. The issue is ......
Read more >
Mouse wheel is zooming instead of scrolling
Most web browsers and some apps have a feature that lets you zoom in and out by pressing and holding the Ctrl key...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found