触摸整个屏幕的手势
Touch Gesture for the entire screen
我是为Windows编写程序的新手。抱歉,如果我的问题是一个非常简单或基本的问题。
我正在尝试编写一个代码,该代码使用Microsoft为Windows 10使用C 提供的触摸手势API。我也在使用触摸屏监视器。
我能够创建一个窗口和一个手柄,以使用下面的代码中提到的触摸手势:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK DecodeGesture(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = {};
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
// Create the window.
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
// Run the message loop.
MSG msg = {};
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
EndPaint(hwnd, &ps);
}
return 0;
case WM_GESTURE:
// Insert handler code here to interpret the gesture.
return DecodeGesture(hwnd, uMsg, wParam, lParam);
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
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
// Get all instances of the onscreen keyboard running on the local computer.
// This will return an empty array if onscreen keyboard isn't running.
array<Process^>^localByName = Process::GetProcessesByName("osk");
if (localByName->Length < 1)
{
system("start powershell.exe Set-ExecutionPolicy RemoteSigned n");
system("start powershell.exe osk");
//system("pause");
}
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);
}
}
//----------------------------------------------------------------------//
显然,上述代码指向一个手柄,那是一个窗口,而不是整个屏幕。
如何修改此代码以创建一个将指向整个屏幕的句柄,而不仅仅是该窗口内的区域?
上述方法不正确,并且使用全局钩的概念可以实现。
您可以挂在某种触摸手势上,并因此填充屏幕键盘
相关文章:
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 如何在GTK程序运行时禁用屏幕保护程序/电源管理/屏幕消隐
- 使用 SFML 和 C++ 将 Pixel 打印到屏幕上
- 在 Windows 8/10 技术中完全实时的屏幕捕获,没有延迟
- Winapi:屏幕截图未显示在窗口中
- 如何在快板的屏幕中显示子位图的绘制?
- 按回车键后输出屏幕关闭
- 要在屏幕上绘制一些小瓷砖,我应该使用 QQuickItem 还是 QQuickPaintedItem?
- SFML 向下移动时如何围绕屏幕中心旋转?
- 截取屏幕截图后程序卡住
- 检测 OpenCV C++窗口上的触摸
- C++鼠标单击时的屏幕截图不起作用
- 屏幕插入运算符<<的运算符过载问题
- 获取网格中心的屏幕位置
- SFML 中的字体.信息不显示在屏幕上.显示的不是信息,而是点
- 不触摸屏幕时的Android(Juce)性能问题
- 触摸整个屏幕的手势
- 双击(触摸)按屏幕按钮的原因可能是什么,该按钮通过单击鼠标按下
- 正在检测屏幕的触摸属性
- 如何在Qml中做一个动作,每次用户触摸屏幕