私はWindows用のプログラムを書くのが初めてです。私の質問が非常に簡単で基本的なものであれば、申し訳ありません。画面全体のタッチジェスチャー
C++を使用してWindows 10にMicrosoftが提供するタッチジェスチャーAPIを使用するコードを作成しようとしています。私はタッチスクリーンモニターも使用しています。
Iは、以下のコードで述べたように、タッチジェスチャーを使用することにウィンドウハンドルを作成することができた:
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);
}
}
//----------------------------------------------------------------------//
明らかに、上記ハンドルにコードポイントを述べ、それはウィンドウであります画面全体ではありません。
このコードを変更して、そのウィンドウ内の領域だけでなく画面全体を指すハンドルを作成するにはどうすればよいですか?
を画面上のキーボードを読み込むことができますか? – user0042
オペレーティングシステム全体では、作成したウィンドウが占める領域ではなく、ユーザーインターフェイス全体を意味します。 – Roger1990
_デスクトップは言い換えれば? – user0042