I. Windows 7 llega con la gestión de multi-touch? ¿Qué son los mensajes de Windows Asociados?
A pesar de la multi-touch no es nuevo como tal, Windows 7 es el primer sistema operativo de Microsoft proporciona soporte nativo para esta tecnología.
Para apoyar esta tecnología, varios mensajes de Windows se han añadido al sistema, incluyendo:
- WM_TOUCH : ¿Quién puede recuperar la información relacionada con la presión en la pantalla (número total de las presiones, coordenadas, etc ...)
- WM_GESTURE : ¿Quién puede obtener un movimiento (gesto) individuales, dirigidas por el usuario en la superficie de la pantalla. Windows 7 reconoce de forma nativa varios gestos, como la rotación, la escala (zoom in y zoom), la presión sobre la pantalla, la distancia entre dos dedos.
Gestion du message WM_TOUCH
case
WM_TOUCH:
{
//
Un
message
WM_TOUCH
peut
contenir
plusieurs
messages
provenant
de
differents
contactes
unsigned int
numInputs =
(int
) wParam;
//
Nombres
de
contactes
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;
}
Gestion du message WM_GESTURE
//
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 multi-touch : http://msdn.microsoft.com/fr-fr/magazine/ee336016.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
No hay comentarios:
Publicar un comentario