Windows 10:笔(手写笔)在MFC应用程序上不起作用 [英] Windows 10 : Pen (stylus) not working on MFC application

查看:256
本文介绍了Windows 10:笔(手写笔)在MFC应用程序上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以与Pen( Stylus )兼容的MFC应用程序. Windows 7,但不幸的是,它在Windows 10上不起作用.

I have an MFC application that works fine with Pen (Stylus) under Windows 7, but unfortunately, it does not work on Windows 10.

  • Windows 7 下,无需使用(单击并拖动)滚动条,即可使用触控笔垂直滚动,我可以通过单击并从对话框中的任何地方(formview)
  • Windows 10 下,如果没有使用(单击并拖动)滚动条,则无法使用触控笔垂直滚动.我必须使用滚动条上的手写笔单击(并拖动)才能垂直滚动
  • Under Windows 7, I am able to scroll vertically with the stylus WITHOUT using (clicking and dragging) the scroll bar, i can scroll vertically by clicking and dragging from anywhere in my dialog (formview)
  • Under Windows 10, I am not able to scroll vertically with the stylus WITHOUT using (clicking and dragging) the scroll bar. I must click (and drag) with the Stylus on the scroll bar to scroll vertically

我的需要:
我需要能够使用触控笔垂直滚动,而无需使用(单击和拖动)Windows 10上的滚动条

My need :
I need to be able to scroll vertically with the stylus WITHOUT using (clicking and dragging) the scroll bar on Windows 10

详细信息:
我在使用Visual Studio 2010的Windows 10上.

Detail:
I am on Windows 10 with Visual studio 2010.

我的观点
我认为 MFC100.dll 的版本(与我的Visual Studio 2010有关)可能不支持Windows 10下手写笔的功能,因为该代码在Windows 7下可以正常工作

My opinion
I think that the version of MFC100.dll (related to my Visual Studio 2010) does probably not support the functionality of the stylus under Windows 10 because the code works correctly under windows 7

有人已经遇到了这个问题吗? 谢谢.

Someone has already encountered this problem ? Thanks.

推荐答案

我发布此答案以帮助与我处境相同的人.

I post this answer to help people who are in the same situation as me.

1.简介

可以使用(可能不是唯一的方法)与滚动条进行交互:

Interaction with the scrollbar can be can be done using (It’s probably not the only methods that exist):

  • SetScrollPos coupled with ScrollWindow. The first scrolls the bare scroll, the second scrolls the contents of the window
  • ScrollToPosition which scrolls both the scroll bare and the contents of the window

第一种方法( SetScrollPos 加上 ScrollWindow )要求管理所有滚动条信息:可滚动大小,当前位置...,并在每个OnSize()上重新计算(这不太琐碎...)

The first method (SetScrollPos coupled with ScrollWindow) requires management of all scrollbar informations : scrollable size, current position, ... and recalculate it on each OnSize () (which is not too trivial ...)

使用seconde方法(

With the seconde method (ScrollToPosition) mode, all we have to do is to call the ScrollToPosition with the desired scrolling size. We don't have to manage the details of the scroll bare, Windows does it for us!

由于某种原因,我不知道,Windows 10上的stylus滚动功能在Windows 7上没有相同的行为:滚动条滚动但不滚动窗口内容 !!!

For some reason that I don't know, the stylus scroll functionality on Windows 10 does not have the same behavior on Windows 7 : The scrollbar scrolls but not the contents of the window !!!

2.解决方案

在这个问题上已经花费了几个小时,我得出结论,解决此问题的简单解决方案是使用

Having spent several hours on this problem, I conclude that the simple solution to work around this problem is to use the ScrollToPosition function as much as possible. And in this case, you just need to calculate scrolled size (delta) which is defined by:

  • Starts when the mouse button is pressed (Stulys pointed) (use ON_WM_LBUTTONDOWN)
  • Extended/reduced during drag (use ON_WM_MOUSEMOVE)
  • Ends when the button is released (use ON_WM_LBUTTONUP)

所有您需要做的就是使用计算出的delta调用ScrollToPosition函数.这将使您从极其复杂的管理模式转变为以下几样:

All you have to do is call the ScrollToPosition function with the calculated delta. This will allow you to move from an extremely complicated management mode to a few things that look like this:

ON_WM_LBUTTONDOWN

void CMyView::OnLButtonDown (UINT nFlags, CPoint point) 
{
    // Code here ...
    POINT p;
    GetCursorPos(&p);
    ScreenToClient ( &p); // Convert to screen coordinates

    m_dragPosition = p; // m_dragPosition : member variable to store click position
    m_bMouseDown = true; // Set Flag to true

    CWnd::OnLButtonDown (nFlags, point) ;
}  

ON_WM_LBUTTONUP

void CMyView::OnLButtonUp (UINT nFlags, CPoint point) 
{
    // Code here ...  
    m_bMouseDown = false;
    CWnd::OnLButtonUp(nFlags, point);
}

ON_WM_MOUSEMOVE

void CMyView::OnMouseMove(UINT nFlags, CPoint point) 
{
   int delta = p.y - m_dragPosition.y;

   // Use absolute value to take into account top/bottom scrolling
   if ( abs (delta) > SCROLLING_STEP_SIZE)
   {
       CPoint pp = GetScrollPosition (); // Get current scrollbar position
       pp.y += -delta;
       pp.x = 0;  // I'm intersting only for vertical scrolling
       ScrollToPosition (pp);   // Scroll to new position
       UpdateWindow (); // This redraw new showed area
       m_dragPosition = p; // Update drag position
   }
}  

通过添加此内容,可以避免显式管理,这一点都不琐碎...
希望这会帮助那些和我一样处境的人

By adding this, you avoid explicit management which is not at all trivial...
Hope this will help those who are in the same situation as me

这篇关于Windows 10:笔(手写笔)在MFC应用程序上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆