블로그 이미지
안녕1999

카테고리

전체 (3067)
자바스크립트 (20)
안드로이드 (14)
WebGL (4)
변비 (17)
정치,경제 (35)
C언어,ARM (162)
컴퓨터(PC, Note Book, 윈.. (41)
전자회로, PCB (27)
유머,안웃긴,GIF,동영상 (118)
국부론60 (71)
모듈(PCB) (3)
건강 (2)
FreeCAD (25)
PADS (43)
퇴직,퇴사,구직,취업 활동 (3)
C# (86)
엑셀 (8)
워드 (0)
LabView (6)
레고 (30)
FPGA (0)
Total
Today
Yesterday

달력

« » 2024.5
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

공지사항

최근에 올라온 글

'WM_TOUCH'에 해당되는 글 2건

  1. 2016.08.16 WM_TOUCH, WM_POINTERDOWN 2
  2. 2016.08.13 WM_TOUCH

WM_POINTERDOWN 먼져 확인하세요.


Windows.h

User32.dll

VC++6.0과 같이 오래된 컴파일러에는 없으므로, DLL함수를 얻어서 호출한다.


윈도우7인 경우, WM_GESTURE나 WM_TOUCH를 사용하고,

윈도우8 이상인 경우, WM_POINTERUPDATE를 사용하라.



Windows 7이상

펜,터치 공용으로 동작 안될 수 있다.


WM_GESTURE나 WM_TOUCH를 사용할 수 있지만, 동시에 받을 수 는 없다.

WM_TOUCH를 받으려면, RegisterTouchWindow설정을 해주어야 한다.


RegisterTouchWindow를 설정해주면, WM_TOUCH 에세지를 받을 수 있다.


BOOL WINAPI GetTouchInputInfo(
  _In_  HTOUCHINPUT hTouchInput,
  _In_  UINT        cInputs,
  _Out_ PTOUCHINPUT pInputs,
  _In_  int         cbSize
);







Windows 8이상

//펜,터치 모두 동작하는 메세지. 윈도우8이상

//https://github.com/Nomad1/touchmouse/blob/master/trunk/TouchMouse/main.cpp

//https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/5aa943b8-f0f2-4287-ae10-9ae169bac0a5/how-to-send-redirected-touch-message-back-to-store-apps?forum=windowsaccessibilityandautomation

#define WM_POINTERDEVICECHANGE 0x0238 

#define WM_POINTERDEVICEINRANGE 0x0239 

#define WM_POINTERDEVICEOUTOFRANGE 0x023A 


#define WM_NCPOINTERUPDATE 0x0241 

#define WM_NCPOINTERDOWN 0x0242 

#define WM_NCPOINTERUP 0x0243 


#define WM_POINTERUPDATE 0x0245 

#define WM_POINTERDOWN 0x0246 

#define WM_POINTERUP 0x0247 


#define WM_POINTERENTER 0x0249 

#define WM_POINTERLEAVE 0x024A 

#define WM_POINTERACTIVATE 0x024B 

#define WM_POINTERCAPTURECHANGED 0x024C 

#define WM_TOUCHHITTESTING 0x024D 

#define WM_POINTERWHEEL 0x024E 

#define WM_POINTERHWHEEL 0x024F



EnableMouseInPointer

한번만 호출하며, 호출해야 WM_POINTER관련 메세지를 받을 수 있다.

WINAPI EnableMouseInPointer(
  _In_ BOOL fEnable
);
BOOL WINAPI IsMouseInPointerEnabled(void);


GetPointerInfo

WM_POINTERxxx메세지를 받았을때, 터치 정보를 얻는다.

실시간으로 날라오면, 프로그램에서 모두 처리하기 어려울 수 도 있다. 가능하면, GetPointerInfoHistory 를 사용하자.

BOOL WINAPI GetPointerInfo(
  _In_  UINT32       pointerId,
  _Out_ POINTER_INFO *pointerInfo
);
typedef struct tagPOINTER_INFO {
  POINTER_INPUT_TYPE         pointerType;
  UINT32                     pointerId;
  UINT32                     frameId;
  POINTER_FLAGS              pointerFlags;
  HANDLE                     sourceDevice;
  HWND                       hwndTarget;
  POINT                      ptPixelLocation;
  POINT                      ptHimetricLocation;
  POINT                      ptPixelLocationRaw;
  POINT                      ptHimetricLocationRaw;
  DWORD                      dwTime;
  UINT32                     historyCount;
  INT32                      inputData;
  DWORD                      dwKeyStates;
  UINT64                     PerformanceCount;
  POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
} POINTER_INFO;



GetPointerInfoHistory 

WM_POINTERUPDATE 메세지를 받았을때 호출한다.

BOOL WINAPI GetPointerInfoHistory(
  _In_      UINT32       pointerId,
  _Inout_   UINT32       *entriesCount,
  _Out_opt_ POINTER_INFO *pointerInfo
);






BOOL WINAPI IsTouchWindow(
  _In_      HWND   hWnd,
  _Out_opt_ PULONG pulFlags 

); 


RegisterTouchWindow


GetTouchInputInfo





WM_POINTERxxx관련 메세지를 처리할때,

pointerType을 얻어서, touch,pen등을 구분하여 처리하는 샘플코드가 있다.

UINT32 id=GET_POINTERID_WPARAM(pMsg->wParam);

POINTER_TYPE pointerType = PT_POINTER;

if(!GetPointerType(id,&pointerType))

{

// failure,call GetLastError()

// set PT_POINTER to fall to default case below

pointerType = PT_POINTER;

}

switch(pointerType)

{

case PT_TOUCH:

POINTER_TOUCH_INFO touchInfo;

if(GetPointerTouchInfo(id,&touchInfo))

{

POINT point;

Point.X = touchInfo.pointerInfo.ptPixelLocationRaw.x;

point.y = touchInfo.pointerInfo.ptPixelLocationRaw.y;

AccNotifyTouchInteraction(hwnd,GetForegroundWindow(),point);

}

break;

case PT_PEN:

POINTER_PEN_INFO penInfo;

if(!GetPointerPenInfo(id,&penInfo))

{

// failure,call GetLastError()

}

else

{

// success,process penInfo

// mark as handled to skip call to DefWindowProc

fHandled = TRUE;

}

break;

default:

if(!GetPointerInfo(id,&pointerInfo)) 

{

// failure.

else 

{

// success,proceed with pointerInfo.

fHandled = HandleGenericPointerInfo(&pointerInfo);

}

break;

그러나, default로 POINTER_INFO정보를 바로 얻을 수 도 있다.

POINTER_TOUCH_INFO나, POINTER_PEN_INFO에는 POINTER_INFO가 들어 있다.

따라서, pen,touch 구분할 필요가 없는 경우, 그냥 GetPointerInfo함수로 POINTER_INFO를 얻으면 된다.

typedef struct tagPOINTER_TOUCH_INFO{

POINTER_INFO pointerInfo;
Touch Flags touchFlags;
Touch Mask touchMask;
RECT rcContact;
RECT rcContactRaw;
UINT32 orientation;
UINT32 pressure;
} POINTER_TOUCH_INFO;
typedef struct tagPOINTER_PEN_INFO{
POINTER_INFO pointerInfo;
PEN_FLAGS penFlags;
PEN_MASK penMask;
UINT32 pressure;
UINT32 rotation;
INT32 tiltX;
INT32 tiltY;

} POINTER_PEN_INFO; 

그러나 pen인 경우, 압력정보(pressure)가 필요하다면, pen정보를 얻어와야 한다.




Posted by 안녕1999
, |

WM_TOUCH

카테고리 없음 / 2016. 8. 13. 23:30

WM_TOUCH


멀티터치 관련 메세지

윈도우7 이상부터 지원




Manipulations and Inertia Programming Guide
Windows Touch Input Programming Guide

 MSDN 코드 샘플

 UINT cInputs = LOWORD(wParam);

PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];

if (NULL != pInputs)

{

    if (GetTouchInputInfo((HTOUCHINPUT)lParam,

                          cInputs,

                          pInputs,

                          sizeof(TOUCHINPUT)))

    {

        // process pInputs

        if (!CloseTouchInputHandle((HTOUCHINPUT)lParam))

        {

            // error handling

        }

    }

    else

    {

        // GetLastError() and error handling

    }

    delete [] pInputs;

}

else

{

    // error handling, presumably out of memory

}

return DefWindowProc(hWnd, message, wParam, lParam);



관련 한글 블로그

  1. Windows 7 멀티터치 시작하기
  2. 미리 정의된 9가지 제스쳐 지원하기 (WM_GESTURE)
  3. 멀티터치 Raw 데이터를 사용 (WM_TOUCH)
  4. Manipulation and Inertia 활용
  5. WPF4 멀티터치 프로그래밍
  6. 실버라이트 4의 멀티터치 프로그래밍

 

Posted by 안녕1999
, |

최근에 달린 댓글

글 보관함