The current way to do this is to handle WM_POINTERnnn msgs. Please note that this is for Win 8 and later.
Please note that you will receive these messages for touch and manual, so you will need to find out the pointerType type to check for a pen. The WPARAM received by WNDPROC for WM_POINTERnnnnn msgs, such WM_POINTERUPDATE and other messages, contains a pointer identifier that you will need to request additional information. Empirically, I found that WM_POINTERUPDATE leads to information that contains pressure data, whereas if the pointer flags point up / down, there is no pressure information.
const WORD wid = GET_POINTERID_WPARAM(wParam); POINTER_INFO piTemp = {NULL}; GetPointerInfo(wid, &piTemp); if (piTemp.pointerType == PT_PEN { UINT32 entries = 0; UINT32 pointers = 0; GetPointerFramePenInfoHistory(wid, &entries, &pointers, NULL);
Once you know that you are dealing with a pen, you can get pressure information from the POINTER_PEN_INFO structure.
It is like touching a touch, although when you touch, you need to recognize a gesture and inertia. There is a Microsoft example illustrating the use of these features.
This is part of the conversation about construction: https://channel9.msdn.com/Events/Build/2013/4-022
kalbr
source share