5

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Steve Maughan
  • 1,174
  • 3
  • 19
  • 30
  • How is this done using MS tools? – David Heffernan Jan 31 '16 at 22:20
  • Haven't tried any of this in Delphi, but have you tried a WinTab wrapper? WinTab API works for most pens/tablets, so I'd expect it to be compatible with Surface Pen(?) A quick google shows this [link](http://torry.net/authorsmore.php?id=3366&sort=Date) TTablet v1.3.1 which might work - (only mentions D5,D6,D7 support though) probably other WinTab wrappers out there? – Matt Coubrough Jan 31 '16 at 22:25
  • @DavidHeffernan There is little out there for MS technology. I found little for C# but I need to look more. I think I'll probably need to find something and convert it. – Steve Maughan Feb 01 '16 at 12:42
  • @MattCoubrough thanks - I'll take a look. I should also mention I'm interested in knowing if the eraser is being used and the pressure. I'm thinking that WinTab won't have this; but I'll still take a look. – Steve Maughan Feb 01 '16 at 12:43
  • That sounds wrong. Surface is an MS device. MS provide the SDK. – David Heffernan Feb 01 '16 at 12:46
  • Interesting comments here. The C++ surface pro 2 pen code samples at the link below don't work with surface pro 3 pens. https://code.msdn.microsoft.com/windowsapps/Input-simplified-ink-sample-11614bbf/view/Discussions – Warren P Feb 01 '16 at 19:41

1 Answers1

1

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;
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219