Buttons reaction on finger's touch in Windows 7

主宰稳场 提交于 2019-12-14 03:13:16

问题


I have Windows 7 with touchscreen attached. My standard Windows Forms Application has several standard buttons.

My problem: buttons on form do not show reaction when I click on them using my finger. My form shows that there has been a click on the button but button itself does not react.

If I use cursor - everything works fine. If I use Windows XP - everything works fine.

Same thing with any standard application like calc.exe


回答1:


I performed several experiments and now I believe problem with buttons reactions on touch is solved.

1) Using WndProc I noticed that WM_LBUTTONDOWN and WM_LBUTTONUP messages were comming to my window at one and the same time (on finger release).

2) I installed most recent driver, found setting Touch Mode and changed it to Mouse Emulation. This resolved the problem for my single touch screen. But problem remained the same for the multi touch screen.

3) I created class:

class TouchButton : Button
{
    protected override void OnHandleCreated(EventArgs e)
    {
        base.OnHandleCreated(e);
        RegisterTouchWindow(Handle, 0);
    }

    protected override void OnHandleDestroyed(EventArgs e)
    {
        UnregisterTouchWindow(Handle);
        base.OnHandleDestroyed(e);
    }
}

4) I replaced all the generic Buttons with the TouchButtons and problem has gone!



来源:https://stackoverflow.com/questions/27175656/buttons-reaction-on-fingers-touch-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!