Skip to content

Instantly share code, notes, and snippets.

@habibg1232191
Created June 12, 2022 17:51
Show Gist options
  • Select an option

  • Save habibg1232191/9a351a146683af2c71a8690c352bb7e1 to your computer and use it in GitHub Desktop.

Select an option

Save habibg1232191/9a351a146683af2c71a8690c352bb7e1 to your computer and use it in GitHub Desktop.
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