How To Program in Delphi for Microsoft's Surface Pen?

694 views Asked by At

I'd like to integrate surface pen capabilities into my application. It's written using Delphi 10 Seattle. I've searched all over the web and can't find anything.

Does anyone know how to program for the Pen? Specifically, to capture the pressure level, pen down, pen up and pen move events.

1

There are 1 answers

0
Ian Boyd On

Your application needs to handle the WM_POINTERUPDATE message.

During that message you can call GetPointerPenInfo to retrieve information about the current status of the pointer as a POINTER_PEN_INFO structure:

POINTER_PEN_INFO = record
   pointerInfo: POINTER_INFO;
   penFlags: PEN_FLAGS;
   penMask: PEN_MASK;
   pressure: UINT32;
   rotation UINT32;
   tiltX: INT32; 
   tiltY: INT32;
end;