1

Consider fullscreen C# WinForms app using the approach as described in the WinForms fullscreen question running on Windows 10. When user uses the "swipe" touch gesture for scrolling (e.g. on multiline TextBox) and reaches either of the extrema there is an effect that pulls entire window in scroll direction revealing desktop. This is not desirable for fullscreen app. How can I get rid of the effect?


Minimal example:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        FormBorderStyle = FormBorderStyle.None;
        WindowState = FormWindowState.Maximized;
        var tb = new TextBox() { Multiline = true, 
                                 ScrollBars = ScrollBars.Vertical, 
                                 Dock = DockStyle.Fill, 
                                 Text = string.Concat(Enumerable.Repeat("foo! ", 10000)) };
        Controls.Add(tb);
    }
}
wondra
  • 3,271
  • 3
  • 29
  • 48
  • Checkout this question: https://stackoverflow.com/questions/45209729/c-sharp-winform-how-to-prevent-of-moving-complete-window-when-moving-to-end-of It doesn't have answers, but the question author posted some kind of a registry hack in the comments. – default locale May 16 '18 at 08:42
  • @defaultlocale yes, looks like duplicate. I am hesitant to delete this question though, since the other one is poorly worded, tagged and does not contain reproducible example. Or should I suggest an edit for that question perhaps and delete this one? – wondra May 16 '18 at 08:48
  • If you have a solution, you can post it here. Then it is possible [to close the old question as a duplicate](https://meta.stackexchange.com/questions/147643/should-i-vote-to-close-a-duplicate-question-even-though-its-much-newer-and-ha/147651#147651) (one with answers wins). Anyway, there's no need to delete your question, even if it is a duplicate. – default locale May 16 '18 at 08:54
  • Make sure that this answer works first :) And don't delete your question: if it is a duplicate then mark it as such and leave it for the benefit of future users. – default locale May 16 '18 at 09:01
  • 1
    @defaultlocale tested the solution and posted as answer, leaving the decision to community. – wondra May 16 '18 at 09:20

1 Answers1

1

In comments similar answer-less question (credit goes to defaultlocale), there was a mention of possible registry configuration that would prevent such behavior. Testing confirmed it would, though not optimal, be the answer. To reiterate, setting the HKEY_CURRENT_USER\Software\Microsoft\Wisp\Touch key's value Bouncing to 0x0 will "fix" the problem. Luckily this is per-user setting which very desirable (no need for admin rights/account).
The modified minimal example with "fixed" scroll pulling behavior:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        FormBorderStyle = FormBorderStyle.None;
        WindowState = FormWindowState.Maximized;
        var tb = new TextBox() { Multiline = true, ScrollBars = ScrollBars.Vertical, Dock = DockStyle.Fill, Text = string.Concat(Enumerable.Repeat("foo! ", 10000)) };
        Controls.Add(tb);
        DisableBouncing();
        FormClosed += (s, e) => RestoreBouncing();//for brevity just on Close
    }

    int? defaultSetting = null;
    private void DisableBouncing()
    {
        using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Wisp\Touch", true))
        {
            defaultSetting = key.GetValue(@"Bouncing", null) as int?;
            key.SetValue(@"Bouncing", 0x00000000, RegistryValueKind.DWord);
        }
    }

    private void RestoreBouncing()
    {
        using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Wisp\Touch", true))
        {
            key.SetValue(@"Bouncing", defaultSetting ?? 0, RegistryValueKind.DWord);
        }
    }
}
wondra
  • 3,271
  • 3
  • 29
  • 48