Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Incorrect rendering of frameless window when used in conjunction with Windows Api

Incorrect rendering of frameless window when used in conjunction with Windows Api

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 235 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Helge1980
    wrote on last edited by Helge1980
    #1

    Hello!
    I'm trying to draw a frameless window in older Windows versions (WinXp and Win7 with Qt5.2.1 MSVC 2010) with support for the system menu and system resizing, for this I use this approach:

    #include <QApplication>
    #include <QMainWindow>
    #include <Windows.h>
    
    class MainWindow : public QMainWindow
    {
    public:
        MainWindow(QWidget *parent = nullptr) : QMainWindow(parent)
        {
    //        setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
            setGeometry(600,300,600,400);
            HWND hwnd = (HWND)winId();
            LONG style = ::GetWindowLong(hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW;
            ::SetWindowLong(hwnd, GWL_STYLE, style & ~WS_CAPTION);
            SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
        };
    };
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        MainWindow w;
        w.show();
        return app.exec();
    }
    

    But as a result, the window content displayed does not fill the entire client area:

    Screenshot_20240408_124942.png

    If, for example, you minimize and then restore the window, the content size is displayed correctly.
    If in my example I uncomment the line:

    setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    

    then the content, on the contrary, goes down more than necessary.

    Thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved