none
Vertical scrollbar behavior with touch screen

    Question

  • When I swipe up, vertical scrollbar moves down and swiping down makes the scrollbar moves up. Is there any way to stop this behavior of vertical scrollbar ?

    I have explained the question in more detail in the following link

    http://stackoverflow.com/questions/39092215

    From my analysis, I found the following things

    1) Swiping up or down on a control, searches for a vertical scrollbar in child controls

    2) If vertical scrollbar is found, some flag (say changeVerticalBehavior) is set to true.

    3) Once this flag is enabled, it is not disabling. So vertical scrollbar always move in the opposite direction

    My question is,

    1) How to stop the control from searching for a vertical scrollbar ?

    2) What is the flag set on vertical scrollbar that affects the scrolling behavior ? Is it possible to reset it ?

    Note: I mentioned flag here, because I don't have the source code for vertical scrollbar class.

    I submitted a bug report in https://connect.microsoft.com/VisualStudio/feedback/details/3078476


    • Edited by Anandaraj T Tuesday, August 23, 2016 1:49 PM
    Tuesday, August 23, 2016 5:21 AM

All replies

  • When I swipe up, vertical scrollbar moves down and swiping down makes the scrollbar moves up. Is there any way to stop this behavior of vertical scrollbar ?

    I have explained the question in more detail in the following link

    http://stackoverflow.com/questions/39092215

    From my analysis, I found the following things

    1) Swiping up or down on a control, searches for a vertical scrollbar in child controls

    2) If vertical scrollbar is found, some flag (say changeVerticalBehavior) is set to true.

    3) Once this flag is enabled, it is not disabling. So vertical scrollbar always move in the opposite direction

    My question is,

    1) How to stop the control from searching for a vertical scrollbar ?

    2) What is the flag set on vertical scrollbar that affects the scrolling behavior ? Is it possible to reset it ?

    Note: I mentioned flag here, because I don't have the source code for vertical scrollbar class.

    I submitted a bug report in https://connect.microsoft.com/VisualStudio/feedback/details/3078476


    Anyone know this ?

    Wednesday, August 24, 2016 12:34 PM
  • Hi Anandaraj T,

    Have you set the value of RightToLeft property to Yes? If yes, the scroll bar will apply the opposite direction when you drag or move it.

    userControl1.RightToLeft = RightToLeft.Yes;
    Best Regards,
    Li Wang

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 25, 2016 6:27 AM
  • Hi Li Wang,

    No, I did not set the value of RightToLeft. I placed a debugger in ValueChanged event but the value of RightToLeft is No in VScrollBar. Also value of UserControl.RightToLeft is also No

    Following steps will help you to replicate this behavior

    Steps to replicate Bug or behavior - 1

    1) Add VScrollBar as a child to any user control.

    2) Swipe up or down on the user control (not on scrollbar). Vertical scrollbar moves in opposite direction even if there isn't any programmatical connection between content and VScrollBar

    Steps to replicate Bug or behavior - 2

    1) Add VScrollBar as a child to any user control.

    2) Swipe on scrollbar, it will move up during swipe up and down during swipe down (correct behavior)

    3) Swipe up or down on the user control. Vertical scrollbar moves in opposite direction

    4) Now swipe up or down on the vertical scrollbar. Vertical scrollbar starts moving in opposite direction (Buggy behavior, happens only after bug no: 1)

    Thanks,

    Anandaraj

    Friday, August 26, 2016 4:18 AM
  • Hi Anandaraj,

    Thank you for your feedback. I seem a bug, we suggest you post this issue on Microsoft connect site which is aim to accept bugs or issues. Link below is for your reference.

    http://connect.microsoft.com/

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, September 3, 2016 6:57 AM
  • Hi Li Wang,

    I have already submitted a report in the following link,

    https://connect.microsoft.com/VisualStudio/feedback/details/3078476

    Please let me know if any workaround or something to make it work is possible.

    Regards,

    Anandaraj

    Wednesday, September 14, 2016 12:43 PM
  • I think this is not a bug.
    VScrollBar doesn't handle a WM_TOUCH message.
    When an user touches and swipes the scrollbar at the first time, .NET Framework handles WM_TOUCH message and converts it to mouse event or appropriate other. Therefore VScrollBar is clicked and scrolled.
    When an user touches and swipes the content area, .NET Framework handles WM_TOUCH message and converts it to event about swipe scrolling of content area. Immediately after swipe scrolling of content area, even if the user touches and swipes the scrollbar, .NET Framework handles WM_TOUCH message and converts it to event about swipe scrolling of content area during a timed. Because, VScrollBar doesn't handle a WM_TOUCH message directly, and .NET Framework handles it for content area.

    If you use an inherited class from VScrollBar which defined to handle WM_TOUCH message directly,  .NET Framework doesn't handle WM_TOUCH for content area.  

    The following source-code is samples about directrly handling WM_TOUCH.
    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    namespace WindowsFormsApp
    {
    	class TouchVScrollBar : System.Windows.Forms.VScrollBar
    	{
    		[DllImport("user32.dll")]
    		[return: MarshalAs(UnmanagedType.Bool)]
    		public static extern bool RegisterTouchWindow(IntPtr hWnd, uint ulFlags);
    
    		[DllImport("user32.dll")]
    		[return: MarshalAs(UnmanagedType.Bool)]
    		private static extern bool GetTouchInputInfo(IntPtr hTouchInput, int cInputs, [In, Out] TOUCHINPUT[] pInputs, int cbSize);
    
    		public TouchVScrollBar() : base()
    		{
    			bool result = RegisterTouchWindow(this.Handle, 0);
    		}
    		private struct TOUCHINPUT
    		{
    			public int x;
    			public int y;
    			public System.IntPtr hSource;
    			public int dwID;
    			public int dwFlags;
    			public int dwMask;
    			public int dwTime;
    			public System.IntPtr dwExtraInfo;
    			public int cxContact;
    			public int cyContact;
    		}
    
    		private const int WM_TOUCH = 0x0240;
    
    		protected override void WndProc(ref Message m)
    		{
    			switch (m.Msg)
    			{
    				case WM_TOUCH:
    					int inputCount = (int)(m.WParam.ToInt32() & 0xFFFF);
    					TOUCHINPUT[] inputs = new TOUCHINPUT[inputCount];
    					bool result = GetTouchInputInfo(m.LParam, inputCount, inputs, Marshal.SizeOf(inputs[0]));
    
    					Select();					
    					
    					break;
    				default:
    					break;
    			}
    			base.WndProc(ref m);
    		}
    	}
    }
    I confirmed this TouchVScrollBar operates expected.


    • Edited by Sung-uk Park Friday, April 19, 2019 6:07 AM
    • Proposed as answer by Sung-uk Park Friday, April 19, 2019 6:07 AM
    Friday, April 19, 2019 5:54 AM