c++ - 如何使用我自己的坐标而不是 wParam? (使用winapi)

标签 c++ winapi msdn

这是下面的整体代码:

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/

相关文章:

c++ - 如何在另一个类 C++ 中存储对象的引用?

c++ - 在固定模板参数的同时扩展模板类

c++ - 捕获 ListView 控件上的键盘输入,C++

c++ - Win32中的窗口边框宽度和高度 - 我如何获得它?

asp.net-mvc - 下载 ASP.NET MVC 引用并将其与本地 MSDN 库集成

c++ - 除了 what() 之外,C++ 异常是否应该提供额外的细节?

c++ - 用于编辑文本的最小 CPU 和内存开销数据结构?

winapi - 为什么我不能绑定(bind)到 winproc?

c# - 为什么在 C# 中启用多行的 TextBox 控件上禁用 CTRL+A 快捷方式?

winapi - WM_PRINTCLIENT(及相关)文档混淆相关问题