How to disable touch scrolling in WinForms for Windows 10? - c#

Years ago we have developed a WinForms application that was running with Windows 7, but should now run with Windows 10. This application is used on touch screens.
In Windows 7, the user could only scroll DataGridViews and other things using the scrollbar. Since this application is running with Windows 10, the user can also scroll these controls by swiping/dragging the control.
However, we don't want to change the behavior of this application now it is running with a newer Windows version, so we don't want to have this 'touch scrolling' functionality. Only the scrollbars may be used to scroll.
WPF has better touch support for these kind of things (PanningMode on ScrollViewers etc.), but unfortunately we can't migrate this application from WinForms to WPF.
So is there a way to disable this touch scrolling in code for WinForms? Or can it be disabled system wide with a Windows 10 setting or somewhere in the registry?
Thanks!

A colleague found a solution.
In the registry, find key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wisp\Touch\PanningDisabled and set it to 1. Without rebooting, swiping will be disabled.

Related

How to fix c# desktop application form resizing or scaling issue for Windows 11

I have a C# desktop application which is developed in dot net framework 4.6.2. This application is working finr in Win 10. But when same application is run in Win 11, all form controls are disturbed. Like few buttons are totally hidden. Is there any global fix? I don't want to reposition and resize the forms and controlls again for the whole application.
The issue you have is because the Windows 11 computer has a different screen DPI setting. Winforms is notoriously bad at scaling with any setting other than 100%. If you cannot run 100% all the time, then you will have to do some coding magic to detect DPI setting and adjust margins and padding... Or you could redo your UI in WPF, which scales properly at any setting.
Some possible avenues to explore if you rebuild to .NET 4.7+:
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8

How do I invoke or dismiss the touch keyboard in WPF using .NET 4.6.2?

Microsoft's release notes for .NET Framework 4.6.2 includes the following:
"Soft Keyboard support enables automatic invocation and dismissal of the touch keyboard in WPF applications without disabling WPF stylus/touch support on Windows 10. Prior to 4.6.2, WPF applications do not implicitly support the invocation or dismissal of the touch keyboard without disabling WPF stylus/touch support. This is due to a change in the way the touch keyboard tracks focus in applications starting in Windows 8."
The List of Changes likewise states:
"Enable automatic invocation and dismissal of the touch keyboard in WPF applications without disabling WPF stylus/touch support on Windows 10 [178044]"
But I cannot find any indication of HOW to do this, and I cannot find anything in the official API diff that seems to be this.
Can anyone help me find documentation of how to do this thing that I can now allegedly do?
My context is that I have an application that explicitly launches "OSK.exe" when needed. On touch devices with a built-in Windows on-screen keyboard, this results in TWO on-screen keyboards being shown. I want to disable the standard one and only launch "OSK.exe" explicitly.
Thanks!
I think this (especially the comments) should answer your question. The short story is: there is nothing specific to do, but it works only on Win10 anniversary edition.
To disable the soft keyboard, you can do what's indicate in the comments:
WPF on Windows 7 with touch: hide soft keyboard (and the popup icon that enables it)
or
https://blogs.msdn.microsoft.com/winuiautomation/2015/04/26/how-and-why-i-added-an-on-screen-keyboard-to-my-windows-store-app/
If in WPF on Windows 10 anniversary edition, you can override automation peer in TextBox:
protected override AutomationPeer OnCreateAutomationPeer()
{
return new FrameworkElementAutomationPeer(this);
}
On Windows 7 it is enough to put
InputMethod.IsInputMethodEnabled=”False”
Hope it helps.

Winforms app controls change size on production PC

I'm developing a small winforms app for internal use. My dev pc runs Windows 7 however most of the other team members (i.e. the users of the app) are running Windows 8.1. The winforms controls all render slightly differently in Windows 8.1 and this causes some problems such as buttons cutting off text due to size differences.
Is there a way to see how the app will render in Windows 8.1 on my Windows 7 dev PC? Note I'm talking about a regular winforms app, not a Metro style app.
I'm developing in C# using Visual Studio Professional 2013
EDIT
Note that I have now also tried using https://github.com/viperneo/winforms-modernui and I get similar behaviour. I have a DateTimePicker next to a Button and I make their height's the same. On my Windows 7 dev PC this looks correct. However when I run it on a Windows 8 "production" PC the button height is now shorter than the DateTimePicker, things become misaligned in general and some controls even start to partially overlap. The screen resolutions of the two PCs is the same
Check to see what DPI setting that all/each of your users are using. Windows Forms will always render differently with each DPI scaling setting regardless if it is Windows 7 or Windows 8. Takes a fair bit of work in dev and testing with each major DPI increment but it can be done to get a decent look.

Windows Form Application Touch Gesture

We are developing a C#, .NET 4.5 application. On Windows 8.1, whenever a user does touch scrolling on one of the panels in the form, the entire screen application moves just a bit, even if maximized.
Found questions asked where people having similar issues fixed it in WPF by turning off the boundary feedback event, and people who fixed it in Windows 7 by just turning off boundary feedback for all of Windows. However, I can't find anything for disabling this in a standard C# windows form application, and the boundary feedback setting option doesn't seem to exist in the Windows 8 settings.
Any suggestions?
Thanks
I haven't tried this, but I believe you can override the WM_GESTURE message (specifically GID_PAN) and not send it on.
The default code is likely very similar to the example code in UpdatePanningFeedback .

WPF application that claims desktop real estate similar to windows taskbar

I'm building a WPF application that is designed to act as a notification toolbar for sending messages to users of an enterprise software platform. It's a bar that is a specific height, stretching all the way across the bottom of the user's desktop, sitting directly above the Windows taskbar.
What I'd like to do is to have my application "claim" or "reserve" the space it takes up and not allow any applications to load behind it. For example, if you were to resize your windows taskbar and make it larger, it will move icons and shortcuts, and maximizing windows will only use the desktop area that is not already being used by the taskbar.
Any idea how this could be pulled off? It's already set to be the topmost item on the desktop, so that's not my question. Right now if you opened another app and maximized it, then the bottom X pixels will be hidden behind my toolbar application.
(Note that I've added Windows 7 and Windows XP tags - I'd love to be able to implement this functionality on WinXP and up, but if I'm not able to do so on a particular version or versions, I can come up with a workaround)
These are called AppBars in Windows and you can use the SHAppBarMessage function to "dock" your window to a side of a monitor. Then other windows, when maximized, will not obscure the docked window.
Here's a link to a similar question that has more information, including a link to a CodeProject page that walks you through creating one.

Categories