阴影在一个无国界的WinForm [英] Drop Shadow On A Borderless WinForm

查看:227
本文介绍了阴影在一个无国界的WinForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想放弃围绕整个形式的影子就像第一张图片,除了这是一个WPF不是一个WinForm。现在我想砸一个winform相同的阴影。

I'm trying to drop a shadow around the whole form just like the first picture, except that that is a WPF not a WinForm. now i want to drop the same shadow on a winform.

这是我want..¬

不this..¬

推荐答案

在的WinForms,你可以重写表单的保护的CreateParams 属性并添加 CS_DROPSHADOW 标志的类样式。例如:

In WinForms, you can just override the form's protected CreateParams property and add the CS_DROPSHADOW flag to the class styles. For example:

public class ShadowedForm : Form {
    protected override CreateParams CreateParams {
        get {
            const int CS_DROPSHADOW = 0x20000;
            CreateParams cp = base.CreateParams;
            cp.ClassStyle |= CS_DROPSHADOW;
            return cp;
        }
    }

    // ... other code ...
}

不过,需要注意几个问题&hellip的;

But, a couple of caveats…


  1. 此标志只在上面-level窗口。在Win32中发言,这意味着重叠和弹出窗口。它有子窗口(如控制)没有影响。我想我记得听到的地方,这个限制已经从Windows 8中删除,但我不能找到一个链接,确认这一点,我没有Windows 8的安装用于测试目的。

  1. This flag works only on top-level windows. In Win32-speak, that means overlapped and popup windows. It has no effect on child windows (e.g. controls). I thought I remembered hearing somewhere that this limitation had been removed from Windows 8, but I can't find a link confirming this and I don't have Windows 8 installed for testing purposes.

这可能是用户完全禁用此功能。如果是这样,你不会得到阴影,无论你怎么问他们。这是由设计。您的应用程序不应该试图和覆盖此请求。您可以决定阴影是否已启用或P /调用 SystemParametersInfo 功能并通过 SPI_GETDROPSHADOW 标记。

It is possible that the user has disabled this feature altogether. If so, you won't get drop shadows, no matter how you ask for them. That's by design. Your application should not try and override this request. You can determine whether drop shadows are enabled or disabled by P/Invoking the SystemParametersInfo function and passing the SPI_GETDROPSHADOW flag.

Aero主题还增加了阴影顶级窗口。这种效果是独立的,并从 CS_DROPSHADOW 分明,和作品的只有的航空时启用。有没有办法将其关闭,并就各个窗口。此外,由于Aero主题已经从Windows 8中删除,它永远不会有这些阴影。

The Aero theme also adds shadows to top-level windows. This effect is separate and distinct from CS_DROPSHADOW, and works only when Aero is enabled. There's no way to turn it off and on for individual windows. Moreover, since the Aero theme has been removed from Windows 8, it won't ever have these shadows.

这篇关于阴影在一个无国界的WinForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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