Created
June 12, 2022 17:51
-
-
Save habibg1232191/9a351a146683af2c71a8690c352bb7e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
| { | |
| switch (message) | |
| { | |
| case WM_NCHITTEST: { | |
| return 0; | |
| } | |
| default: | |
| { | |
| return DefWindowProc(hWnd, message, wParam, lParam); | |
| } | |
| } | |
| } | |
| class MyEventFilter : public QAbstractNativeEventFilter | |
| { | |
| public: | |
| MyEventFilter(){} | |
| bool nativeEventFilter(const QByteArray &eventType, void *message, long* res) override | |
| { | |
| if (eventType == "windows_generic_MSG") { | |
| res = (long*)WndProc(((MSG*)message)->hwnd, ((MSG*)message)->message, ((MSG*)message)->wParam, ((MSG*)message)->lParam); | |
| } | |
| return true; | |
| } | |
| }; | |
| int main(int argc, char *argv[]) | |
| { | |
| QGuiApplication app(argc, argv); | |
| QQmlApplicationEngine engine; | |
| const QUrl url(QStringLiteral("qrc:/main.qml")); | |
| QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, | |
| &app, [url](QObject *obj, const QUrl &objUrl) { | |
| if (!obj && url == objUrl) | |
| QCoreApplication::exit(-1); | |
| }, Qt::QueuedConnection); | |
| engine.load(url); | |
| app.installNativeEventFilter(new MyEventFilter()); | |
| return app.exec(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment