这是下面的整体代码:
LRESULT WmPointerAPI::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HRESULT hr;
POINTER_INFO pointerInfo = {};
UNREFERENCED_PARAMETER(hr);
switch (message)
{
case WM_POINTERDOWN:
// Get frame id from current message
if (GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pointerInfo))
{
我关注的是:
if (GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pointerInfo))
我目前正在使用 Leap Motion 技术,这是一种 3D 传感器,可将坐标插入我的应用程序中。 问题是,我不知道如何将我自己的“坐标”插入 wParam,以便它接受我的坐标,而不是来自光标/触摸屏。
如何使用我自己的屏幕坐标通过 wParam 注入(inject)或模拟触摸?
最佳答案
l参数
坐标位于lParam
中,参见here :
Use the following macros to retrieve the physical screen coordinates of the point:
* GET_X_LPARAM(lParam): the x (horizontal point) coordinate.
* GET_Y_LPARAM(lParam): the y (vertical point) coordinate.
您可以使用 MAKELPARAM
创建新的 lParam
值宏。示例:
WORD screenX = 345;
WORD screenY = 234;
LPARAM testLParam = MAKELPARAM(screenX, screenY);
wParam
如果您还想创建 wParam
,那么您应该对 in its description 列出的宏读取 wParam
的哪些位进行逆向工程。 ,并使用位运算创建您自己的 wParam
值。例如,GET_POINTERID_WPARAM读取wParam
的低位WORD
。宏MAKEWPARAM也能派上用场。
关于c++ - 如何使用我自己的坐标而不是 wParam? (使用winapi),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18474416/