WinForms可滚动控制触摸行为(WinForms scrollable control touch behavior)

编程入门 行业动态 更新时间:2024-10-22 15:23:32
WinForms可滚动控制触摸行为(WinForms scrollable control touch behavior)

我有一个SplitContainer,其中包含Atalasoft的AnnotateViewer。 类层次结构如下:

System.Windows.Forms.Control Atalasoft.Imaging.WinControls.ScrollPort ... Atalasoft.Annotate.UI.AnnotateViewer My.AnnotateViewer

现在的问题是:只要SplitContainer的内容小于实际视口,因此没有可见的滚动条,触摸输入被解释为鼠标左键,鼠标移动和鼠标左键,这正是我所期待和喜欢的看到。 我仍然可以使用双指平移来滚动视图。 但是:如果我缩放查看器,使我的内容比我的视口大,则会出现滚动条,触摸输入的行为也不同:水平平移保持不变,但垂直平移现在会导致滚动,即使用一根手指也是如此。

问题是:这种行为是特定于Atalasoft,特定于WinForms还是系统特定的,我可以做些什么来改变它吗? 我想要一根手指始终转换为左键单击并移动。 用于滚动的两个手指很好(并且已经有效)。

我担心它是特定于系统的,因为您可以在Word 2010中找到完全相同的行为。但它仍然是Microsoft产品。

I have a SplitContainer which contains Atalasoft's AnnotateViewer. Class hierarchy is as follows:

System.Windows.Forms.Control Atalasoft.Imaging.WinControls.ScrollPort ... Atalasoft.Annotate.UI.AnnotateViewer My.AnnotateViewer

Now the problem: As long as the content of the SplitContainer is smaller than the actual viewport, hence no scrollbars visible, touch input is interpreted as left mouse down, mouse move and left mouse up which is exactly what I'd expect and love to see. I could still use two-finger-panning to scroll the view. BUT: If I zoom the viewer, so that my content gets larger than my viewport, scrollbars appear and touch input behaves differently: Horizontal panning stays the same, but vertical panning now causes scrolling, even with a single finger.

The question is: Is this behavior Atalasoft-specific, WinForms-specific or system-specific and can I do something to change it? I'd like a single finger to always convert to left click and move. Two finger's for scrolling is fine (and already works.)

I fear that it is system specific because you can find the exact same behavior in Word 2010. Still, it's a Microsoft product.

最满意答案

我开始讨厌这样一个事实,即在最终将你的问题输入论坛或类似内容后,你经常得到突然的灵感。

现在通过重新注册手势事件来解决此问题。 您可以注册除水平和/或垂直单指平移之外的所有平移手势。

// adapt the gesture registration for this window GESTURECONFIG[] gestureConfig = new[] { // register for zoom gesture new GESTURECONFIG { dwID = GID_ZOOM, dwWant = GC_ZOOM, dwBlock = 0 }, // register for pan gestures but ignore single finger (only use two-finger-pan to scroll) new GESTURECONFIG { dwID = GID_PAN, dwWant = GC_PAN, dwBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY } }; SetGestureConfig(this.Handle, 0, (uint)gestureConfig.Length, gestureConfig, (uint)Marshal.SizeOf(typeof(GESTURECONFIG)));

详细信息: http : //msdn.microsoft.com/de-de/library/dd353241%28v=vs.85%29.aspx

我认为这是你能得到的最干净的解决方案。

I begin to hate the fact that you so often get sudden inspiration after finally typing down your problem to a forum or similar.

This problem was now solved by re-registering for gesture events. You are able to register for all pan gestures except for horizontal and/or vertical single finger pan.

// adapt the gesture registration for this window GESTURECONFIG[] gestureConfig = new[] { // register for zoom gesture new GESTURECONFIG { dwID = GID_ZOOM, dwWant = GC_ZOOM, dwBlock = 0 }, // register for pan gestures but ignore single finger (only use two-finger-pan to scroll) new GESTURECONFIG { dwID = GID_PAN, dwWant = GC_PAN, dwBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY | GC_PAN_WITH_SINGLE_FINGER_VERTICALLY } }; SetGestureConfig(this.Handle, 0, (uint)gestureConfig.Length, gestureConfig, (uint)Marshal.SizeOf(typeof(GESTURECONFIG)));

Details here: http://msdn.microsoft.com/de-de/library/dd353241%28v=vs.85%29.aspx

I think this is the cleanest solution you can get.

更多推荐

本文发布于:2023-07-05 07:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:scrollable   WinForms   control   behavior   touch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!