spin_eight
spin_eight

Reputation: 4025

Need explanation of syntaxis of Qt 5.0 method native event

I am trying to send a system message from parent process to a child process.
1. I registered message within parent method:

UINT msg = RegisterWindowMessageA("my message");

2.In the child application I override method nativeEvent.
I found syntax of that method in Qt assistant, but info provided not enough, because argument usage not described there.

bool MainWindow::nativeEvent(const QByteArray& eventType, void* message,
        long* result)
{
    UINT mssg = RegisterWindowMessage(L"my message");
    UINT recivedMssg = *static_cast<UINT*>(message);
    if (recivedMssg == mssg)
    {
        *result = 0;
        QMessageBox::information(this,"",QString::number(recivedMssg));
        return true;
    }
    return false;
}

I did this implementation, but it doesn`t work as I expect, I considered that void* message - is number of message.
So my question is: how in nativeEvent I can get message which was sent from the parent process?

Upvotes: 0

Views: 2457

Answers (1)

ixSci
ixSci

Reputation: 13708

I didn't play with Qt5 yet but I doubt that there is any difference. For Windows you should cast message as follows:

MSG* msg = reinterpret_cast<MSG*>(message);

Where MSG is Windows specific structure declared in some Windows header(windows.h will be enough for sure)

Upvotes: 3

Related Questions