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