I. Windows 7 est arrivé avec la gestion du multitouch : quels sont les messages Windows associés ?▲
Bien que le multitouch ne soit pas une nouveauté en tant que telle, Windows 7 est le premier système de Microsoft fournissant un support natif de cette technologie.
Pour supporter cette technologie, plusieurs messages Windows ont été rajoutés au système, dont :
- WM_TOUCH : qui permet de récupérer les informations liées à une pression sur l'écran (nombre de pressions au total, coordonnées, etc.) ;
- WM_GESTURE : qui permet de récupérer un mouvement (un geste) particulier, réalisé par l'utilisateur sur la surface de l'écran. Windows 7 reconnaît nativement plusieurs gestuelles, telles que la rotation, le changement d'échelle (zoom et dézoom), la pression sur l'écran, la distance entre deux doigts.
case WM_TOUCH:
{
// Un message WM_TOUCH peut contenir plusieurs messages provenant de différents contacts
unsigned int numInputs = (int) wParam; // Nombres de contacts
TOUCHINPUT* ti = new TOUCHINPUT[numInputs]; //
if (GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs, ti, sizeof(TOUCHINPUT)))
{
for (unsigned int i=0; i<numInputs; ++i)
{
if (ti[i].dwFlags & TOUCHEVENTF_DOWN)
{
OnTouchDownHandler(hWnd, ti[i]);
}
else if (ti[i].dwFlags & TOUCHEVENTF_MOVE)
{
OnTouchMoveHandler(hWnd, ti[i]);
}
else if (ti[i].dwFlags & TOUCHEVENTF_UP)
{
OnTouchUpHandler(hWnd, ti[i]);
}
}
}
CloseTouchInputHandle((HTOUCHINPUT)lParam);
delete [] ti;
}// Entry point to the application
LRESULT DecodeGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
// Create a structure to populate and retrieve the extra message info.
GESTUREINFO gi;
ZeroMemory(&gi, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
BOOL bResult = GetGestureInfo((HGESTUREINFO)lParam, &gi);
BOOL bHandled = FALSE;
if (bResult){
// now interpret the gesture
switch (gi.dwID){
case GID_ZOOM:
// Code for zooming goes here
bHandled = TRUE;
break;
case GID_PAN:
// Code for panning goes here
bHandled = TRUE;
break;
case GID_ROTATE:
// Code for rotation goes here
bHandled = TRUE;
break;
case GID_TWOFINGERTAP:
// Code for two-finger tap goes here
bHandled = TRUE;
break;
case GID_PRESSANDTAP:
// Code for roll over goes here
bHandled = TRUE;
break;
default:
// A gesture was not recognized
break;
}
}
else
{
DWORD dwErr = GetLastError();
if (dwErr > 0){
//MessageBoxW(hWnd, L"Error!", L"Could not retrieve a GESTUREINFO structure.", MB_OK);
}
}
if (bHandled){
return 0;
}
else
{
return DefWindowProc(hWnd, message, wParam, lParam);
}Pour plus d'infos :
- Pour en savoir plus sur le multitouch : http://msdn.microsoft.com/fr-fr/magazine/ee336016.aspx
- MSDN : http://msdn.microsoft.com/fr-fr/windows/default.aspx
- Le coach Windows 7 : http://msdn.microsoft.com/fr-fr/windows/msdn.coach.windows7
- Kit de développement pour Windows 7 : http://msdn.microsoft.com/fr-fr/windows/gg398052.aspx




