Qt5 如何在不截断的情况下获取 Windows_x64 消息的结果?

How to get the result of Windows_x64 message without truncation in Qt5?

在Qt5中,处理原生Windows消息的函数是:

bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) 

the documentation says, that the third parameter means LRESULT on Windows. In Qt6, the parameter was changed to qintptr:

bool QWidget::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)

现在您可以使用 64 位 qintptr 正确传递 64 位 LRESULT。但是在 Qt5 中使用 32-bit long 在 Windows x64 上应该做什么?

我有一个自定义 MessageHandler,其中 returns 各种使用其 LRESULT 的 8 字节指针,因此来自 nativeEvent 的调用 *result = SendMessage(...) 存储截断的结果。

what should be done on Windows x64?"

不要使用 Qt5。

好吧,您可以将 Qt5 用于您的大部分程序,但不能使用 Qt 来处理此特定消息。您可以做的是子类化 window(请参阅 WinAPI 函数 SetWindowSubclass)并编写您自己的 window 过程,该过程仅处理那条消息,同时允许所有其余消息通过 Qt window 照常进行。

这里有一个关于子类化的微软官方教程:

虽然它谈到子类化子类 window(控制),但同样的技术适用于 top-level windows。