HP TouchSmart 9100 Resources for Developing Touch-Friendly Applications for HP - Page 19

WPF Stylus Events

Page 19 highlights

if (bHandled){ // if you handled the message, close the touch input handle and return CloseTouchInputHandle((HTOUCHINPUT)lParam); return 0; }else{ // if you didn't handle the message, let DefWindowProc handle it return DefWindowProc(hWnd, WM_TOUCH, wParam, lParam); } } Consider the following when handling WM_TOUCH:  Pass unconsumed messages to DefWindowProc to ensure all messages are handled appropriately.  Call CloseTouchInputHandle to close the touch input handle for messages that your application handles.  Be aware that by default, touch messages are coalesced and palm detection are enabled. Palm detection may affect the performance of your application unnecessarily. You can turn both of these off in the call to RegisterTouchWindow.  Note that WM_TOUCH messages are "greedy". Once Windows sends the first touch message to a window, all subsequent touch messages are sent to that window until another window gets focus. Interpreting touch input messages is usually complex. You may want to utilize COMbased manipulation processors and inertia processors to make handling touch input messages easier for you. You can feed raw touch input messages to a manipulation processor and get manipulation delta events back with all the deltas you want to know to respond to touch messages: translation delta, scale delta, expansion delta, rotation delta, etc. With this help, you can respond to gesture combinations like zoom and rotate, or rotate and translate without having to do a lot of calculations yourself. You can also use an inertia processor together with a manipulation processor to simulate object physics. More on manipulations and inertia is available on MSDN, section Manipulations and Inertia at http://msdn.microsoft.com/en-us/library/dd317309(VS.85).aspx. You may also refer to Implementing Windows Touch with Multiple Manipulation Processors blog at http://gclassy.com/2009/08/06/implementing-windows-touchwith-multiple-manipulation-processors/. WPF Stylus Events Besides handling gesture and touch input messages using unmanaged code, you can also utilize stylus events in WPF to get touch data. This path is for those who want to develop with WPF prior to WPF 4.0. Andrew Eichacker showed how to get 19

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

19
if (bHandled){
// if you handled the message, close the touch input handle and
return
CloseTouchInputHandle
((HTOUCHINPUT)lParam);
return 0;
}else{
// if you didn't handle the message, let DefWindowProc handle it
return
DefWindowProc
(hWnd, WM_TOUCH, wParam, lParam);
}
}
Consider the following when handling WM_TOUCH:
Pass unconsumed messages to
DefWindowProc
to ensure all messages are
handled appropriately.
Call
CloseTouchInputHandle
to close the touch input handle for messages that
your application handles.
Be aware that by default, touch messages are coalesced and palm detection
are enabled. Palm detection may affect the performance of your application
unnecessarily. You can turn both of these off in the call to
RegisterTouchWindow
.
Note that WM_TOUCH messages are
greedy
. Once Windows sends the first
touch message to a window, all subsequent touch messages are sent to that
window until another window gets focus.
Interpreting touch input messages is usually complex. You may want to utilize COM-
based manipulation processors and inertia processors to make handling touch input
messages easier for you. You can feed raw touch input messages to a manipulation
processor and get manipulation delta events back with all the deltas you want to
know to respond to touch messages: translation delta, scale delta, expansion delta,
rotation delta, etc. With this help, you can respond to gesture combinations like
zoom and rotate, or rotate and translate without having to do a lot of calculations
yourself. You can also use an inertia processor together with a manipulation
processor to simulate object physics.
More on manipulations and inertia is available on
MSDN
, section
Manipulations
and Inertia
at
.
You may also refer to
Implementing
Windows Touch with Multiple Manipulation
Processors
blog at
http://gclassy.com/2009/08/06/implementing-windows-touch-
with-multiple-manipulation-processors/
.
WPF Stylus Events
Besides handling gesture and touch input messages using unmanaged code, you
can also utilize stylus events in WPF to get touch data. This path is for those who
want to develop with WPF prior to WPF 4.0. Andrew Eichacker showed how to get