qt 处理自定义的windows消息

#include "mainwindow.h"

#include "ui_mainwindow.h"

#include <qt_windows.h>

#include <QDebug>



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

{

    if (eventType == "windows_generic_MSG")

    {

        PMSG msg = (PMSG)message;

        if (msg->message == WM_USER + 777)

        {

            qDebug() << "Hello World";

            qDebug() << msg->wParam;   // 10

            qDebug() << msg->lParam;   // 20

        }

    }

    return false;

}



MainWindow::MainWindow(QWidget *parent) :

    QMainWindow(parent),

    ui(new Ui::MainWindow)

{

    ui->setupUi(this);

}



MainWindow::~MainWindow()

{

    delete ui;

}



void MainWindow::on_pushButton_clicked()

{

    PostMessage((HWND)this->winId(), WM_USER + 777, 10, 20);

}

展开阅读全文

没有更多推荐了,返回首页