好的,
我同意 Marko 的回答,因为现在我有了这个代码。
#include <iostream>
#include <windows.h>
#include <winuser.h>
using namespace std;
LRESULT CALLBACK TestWndProc(HWND in_hWnd, UINT in_uMsg, WPARAM in_wParam, LPARAM in_lParam);
LRESULT CALLBACK TestWndProc(HWND in_hWnd, UINT in_uMsg, WPARAM in_wParam, LPARAM in_lParam)
{
switch (in_uMsg)
{
case WM_TOUCH:
cout << "WM_TOUCH";
UINT cInputs = LOWORD(in_wParam);
PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
if (NULL != pInputs)
{
if (GetTouchInputInfo((HTOUCHINPUT)in_lParam,
cInputs,
pInputs,
sizeof(TOUCHINPUT)))
{
for (int i = 0; i < static_cast<INT>(cInputs); i++) {
TOUCHINPUT ti = pInputs[i];
}
// process pInputs
if (!CloseTouchInputHandle((HTOUCHINPUT)in_lParam))
{
// error handling
}
}
else
{
// GetLastError() and error handling
}
delete[] pInputs;
}
else
{
// error handling, presumably out of memory
}
}
// default processing
return DefWindowProc(in_hWnd, in_uMsg, in_wParam, in_lParam);
}
void main()
{
MSG msg;
BOOL bRet;
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
但恐怕我把这一切都搞砸了。
当手指在触摸板上时,我想向控制台打印一条消息,显示“手指在触摸板上”。
现在我正在尝试找到如何获取 TOUCH_UP 和 TOUCH_DOWN 消息。