diff --git a/app/framelesswindow.cpp b/app/framelesswindow.cpp index 5947ff5..35488b0 100644 --- a/app/framelesswindow.cpp +++ b/app/framelesswindow.cpp @@ -11,6 +11,22 @@ #include #include +#ifdef Q_OS_WIN +#include "windows.h" +void fixWindowStyle(QWidget * that) +{ + HWND hwnd = (HWND)that->winId(); + + LONG style = GetWindowLong(hwnd, GWL_STYLE); + style |= WS_THICKFRAME | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU; + SetWindowLong(hwnd, GWL_STYLE, style); + + SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | + SWP_NOZORDER | SWP_NOACTIVATE); +} +#endif + FramelessWindow::FramelessWindow(QWidget *parent) : QWidget(parent) , m_centralLayout(new QVBoxLayout(this)) @@ -41,6 +57,14 @@ void FramelessWindow::installResizeCapture(QObject* widget) widget->installEventFilter(this); } +void FramelessWindow::showEvent(QShowEvent *event) +{ +#ifdef Q_OS_WIN + fixWindowStyle(this); +#endif // Q_OS_WIN + return QWidget::showEvent(event); +} + bool FramelessWindow::eventFilter(QObject* o, QEvent* e) { switch (e->type()) { diff --git a/app/framelesswindow.h b/app/framelesswindow.h index 2be9618..685e35d 100644 --- a/app/framelesswindow.h +++ b/app/framelesswindow.h @@ -20,6 +20,9 @@ public: void setCentralWidget(QWidget * widget); void installResizeCapture(QObject* widget); +protected slots: + void showEvent(QShowEvent *event) override; + protected: bool eventFilter(QObject *o, QEvent *e) override; bool mouseHover(QHoverEvent* event, QWidget* wg);