HP Dx9000 Resources for Developing Touch-Friendly Applications for HP Business - Page 18

Register to receive touch input messages, Handle the messages

Page 18 highlights

Register to receive touch input messages: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { // pass touch messages to the touch handler case WM_TOUCH: OnTouch(hWnd, wParam, lParam); break; Handle the messages: LRESULT OnTouch(HWND hWnd, WPARAM wParam, LPARAM lParam ){ BOOL bHandled = FALSE; UINT cInputs = LOWORD(wParam); PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs]; if (pInputs){ if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))){ for (UINT i=0; i < cInputs; i++){ TOUCHINPUT ti = pInputs[i]; //do something with each touch input entry } bHandled = TRUE; }else{ /* handle the error here */ } delete [] pInputs; }else{ /* handle the error here, probably out of memory */ } 18

  • 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

18
Register to receive touch input messages:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
// pass touch messages to the touch handler
case
WM_TOUCH
:
OnTouch(hWnd, wParam, lParam);
break;
Handle the messages:
LRESULT OnTouch(HWND hWnd, WPARAM wParam, LPARAM lParam ){
BOOL bHandled = FALSE;
UINT cInputs = LOWORD(wParam);
PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
if (pInputs){
if (
GetTouchInputInfo
((HTOUCHINPUT)lParam, cInputs, pInputs,
sizeof(TOUCHINPUT))){
for (UINT i=0; i < cInputs; i++){
TOUCHINPUT ti = pInputs[i];
//do something with each touch input entry
}
bHandled = TRUE;
}else{
/* handle the error here */
}
delete [] pInputs;
}else{
/* handle the error here, probably out of memory */
}