下面我們就來介紹, 如何關掉某些手勢反應的功能, 基本上, 有兩種方法可以關掉此功能, 第一種就是在系統中修改環境設定, 另一種就是在程式中, 設定MICROSOFT_TABLETPENSERVICE_PROPERTY的flag.
系統設定
1. 打開控制台(Control Panel) ==> 點選Pen and Touch
2. 關掉Flicks, 如下圖所示, 將Use flicks to perform common actions quickly and easily的勾選取消
3. 關掉Touch pointer, 如下圖所示, 將Show the touch pointer when I'm interacting with item on the screen的勾選取消
在程式中修改MICROSOFT_TABLETPENSERVICE_PROPERTY
在tpcshrd.h中, 我們可以找到WM_TABLET_QUERYSYSTEMGESTURESTATUS message 的定義, 下面的flag可以用來開啟或關閉某些手勢
#define TABLET_DISABLE_PRESSANDHOLD 0x00000001
#define TABLET_DISABLE_PENTAPFEEDBACK 0x00000008
#define TABLET_DISABLE_PENBARRELFEEDBACK 0x00000010
#define TABLET_DISABLE_TOUCHUIFORCEON 0x00000100
#define TABLET_DISABLE_TOUCHUIFORCEOFF 0x00000200
#define TABLET_DISABLE_TOUCHSWITCH 0x00008000
#define TABLET_DISABLE_FLICKS 0x00010000
#define TABLET_ENABLE_FLICKSONCONTEXT 0x00020000
#define TABLET_ENABLE_FLICKLEARNINGMODE 0x00040000
#define TABLET_DISABLE_SMOOTHSCROLLING 0x00080000
#define TABLET_DISABLE_FLICKFALLBACKKEYS 0x00100000
#define TABLET_ENABLE_MULTITOUCHDATA 0x01000000
下面的sample code說明如何在Win32的視窗中, 關掉flicks游標:#include<tpcshrd.h>
[...]
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
[...]
const DWORD_PTR dwHwndTabletProperty =
TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click) gesture
TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves)
TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button down
TABLET_DISABLE_FLICKS; // disables pen flicks (back, forward, drag down, drag up)
ATOM atom = GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY);
SetProp(hWnd,
MICROSOFT_TABLETPENSERVICE_PROPERTY,
reinterpret_cast(dwHwndTabletProperty)); GlobalDeleteAtom(atom);
}
參考資料:
http://msdn.microsoft.com/en-us/library/bb969148(VS.85).aspx
我嘗試用上面的代碼,可是編譯過程總是報錯,是MICROSOFT_TABLETPENSERVICE_PROPERTY的定義問題,不知道怎么解決呢?
回覆刪除你有引用tpcshrd的標頭檔嗎?
回覆刪除#include "tpcshrd.h"