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

130 views Asked by At

In Qt5, the function for processing native Windows messages is:

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

and 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)

Now you can properly pass 64-bit LRESULT using 64-bit qintptr. But what should be done on Windows x64 with 32-bit long in Qt5?

I have a custom MessageHandler which returns various 8-byte pointers using its LRESULT, so the call *result = SendMessage(...) from nativeEvent stores the truncated result.

1

There are 1 answers

0
Ben Voigt On BEST ANSWER

what should be done on Windows x64?"

Don't use Qt5.

Well, you can use Qt5 for most of your program, but you can't use Qt for processing this particular message. What you can do is subclass the window (see WinAPI function SetWindowSubclass) and write your own window procedure which processes only that single message, while allowing all the rest to process through the Qt window procedure as usual.

Here is an official Microsoft tutorial on subclassing:

While it talks about subclassing a child window (control), the same technique works fine for top-level windows.