qtdevs/FramelessHelper

在win7系统没有阴影边框 鼠标拖动到屏幕左上右边缘没有系统的动画效果

Opened this issue · 4 comments

鼠标拖动到屏幕左上右边缘没有系统的动画效果,且鼠标光标会圈圈
image
image
是在win7虚拟机测试的

same problem, and cannot maximized when double click header.

源码中的 if (currentVersion < QOperatingSystemVersion::Windows8) 未对win8以下的系统进行处理,
同时,在win10下某些机器上会导致显示错位的的问题

void NativeWindowHelperPrivate::updateWindowStyle()
{
    Q_Q(NativeWindowHelper);

    Q_CHECK_PTR(window);

    HWND hWnd = reinterpret_cast<HWND>(window->winId());
    if (NULL == hWnd)
        return;
    else if (oldWindow == hWnd)
    {
        return;
    }
    oldWindow = hWnd;

    NativeWindowFilter::deliver(window, q);

    QOperatingSystemVersion currentVersion = QOperatingSystemVersion::current();
    if (currentVersion < QOperatingSystemVersion::Windows8)
    {
        return;
    }

    LONG oldStyle = WS_OVERLAPPEDWINDOW | WS_THICKFRAME
                    | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;;
    LONG newStyle = WS_POPUP            | WS_THICKFRAME;

    if (QtWin::isCompositionEnabled())
        newStyle |= WS_CAPTION;

    if (window->flags() & Qt::CustomizeWindowHint)
    {
        if (window->flags() & Qt::WindowSystemMenuHint)
            newStyle |= WS_SYSMENU;
        if (window->flags() & Qt::WindowMinimizeButtonHint)
            newStyle |= WS_MINIMIZEBOX;
        if (window->flags() & Qt::WindowMaximizeButtonHint)
            newStyle |= WS_MAXIMIZEBOX;
    }
    else
    {
        newStyle |= WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
    }

    LONG currentStyle = GetWindowLong(hWnd, GWL_STYLE);
    SetWindowLong(hWnd, GWL_STYLE, (currentStyle & ~oldStyle) | newStyle);


    SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
    SWP_NOOWNERZORDER | SWP_NOZORDER |
    SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);

    if (QtWin::isCompositionEnabled())
        QtWin::extendFrameIntoClientArea(window, 1, 1, 1, 1);
}

@hcaihao @564398053 内容显示错乱,两位大佬有好的解决方法吗?

Try StyleWindow in my repositories.