无边框窗口使用Areo捕捉,阴影,最小化动画和摇动 [英] Borderless Window Using Areo Snap, Shadow, Minimize Animation, and Shake

查看:1498
本文介绍了无边框窗口使用Areo捕捉,阴影,最小化动画和摇动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上使用无边框窗口进行应用程序。但是,由于窗口是无边框的,我没有阴影,捕捉,最小化动画或摇动。我看了看,发现没有网站解释如何实现这一点。但是,我知道这是可能的,因为Office 2013,Visual Studio 2012和Steam都有这些功能,是无边框的。我特别使用QT和C ++,但如果你已经解决了这个另一个窗口库,我想听到你的解决方案以及。或者。并且通过areo阴影我不意味着阴影在两边,我的意思是所有活动的本机areo windows应用程序的所有方面发光的阴影。非常感谢您的帮助。

解决方案

使用Spy ++检查Steam的窗口(窗口样式,消息),并尝试匹配它所做的一切,结合来自此,F11切换无边框/窗口模式,F12切换无边框阴影开/关。


I am making a application with a borderless window on Windows. However, since the window is borderless, I have no areo shadow, snap, minimization animation, or shake. I have looked around and found no site that explains how to implement this. However, I know it is possible because Office 2013, Visual Studio 2012, and Steam all have these features and are borderless. I am specifically using QT and c++ but if you have solved this for another windowing library I would like to hear your solutions as well. either. And by areo shadow I don't mean drop shadow on two sides, I mean the glowing shadow on all sides of all active native areo windows applications. Thank you so much for your help.

解决方案

After using Spy++ to inspect Steam's window (its window styles, how it replies to window messages) and trying to match everything it does, combined with the DWMAPI calls from this C# borderless window behavior, I believe I figured it out.

To hide the window's border, handle the WM_NCCALCSIZE message in your WindowProc:

case WM_NCCALCSIZE:
    {
        if (window->is_borderless) return 0;
        else return DefWindowProc(hwnd, msg, wparam, lparam);
    }

To enable the shadow, all you need to do is:

MARGINS borderless = {1,1,1,1};
DwmExtendFrameIntoClientArea(hwnd, &borderless);

To turn it back off, restore the default margins MARGINS windowed = {0,0,0,0};. Perhaps throw in a SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_NOSIZE | SWP_NOMOVE ); also, to make sure the frame gets redrawn.

However, this does not seem to work with all window styles, apparently your window style must not contain a titlebar title bars work fine, and adding one seems to enable the minimize animation.

The simplest window style I got the shadow to work with was WS_POPUP | WS_THICKFRAME, to also get aero snap, maximizing, minimizing, and the smooth minimize animation I used WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION.

Changing DWMWA_NCRENDERING_POLICY or DWMWA_ALLOW_NCPAINT via DwmSetWindowAttribute does not appear to be required, the default settings seem to work.

One word of caution: DwmExtendFrameIntoClientArea does exactly what the name suggests, so if you are drawing an image with an alpha channel directly into your client area (say with opengl, direct3d/2d), a small frame will be visible through it:

So you might have to put a non transparent widget, brush or something behind the transparent element.

If all goes well, it should then look like this:

Here is a small example project, F11 toggles borderless/windowed mode, F12 toggles the borderless shadow on and off.

这篇关于无边框窗口使用Areo捕捉,阴影,最小化动画和摇动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆