【问题标题】:Irregular shaped Windows Form (C#)不规则形状的 Windows 窗体 (C#)
【发布时间】:2008-10-06 23:47:17
【问题描述】:

最简单的方法是什么?是否可以使用托管代码?

【问题讨论】:

标签: c# .net winforms


【解决方案1】:
this.BackgroundImage = //Image
this.FormBorderStyle = FormBorderStyle.None;
this.Width = this.BackgroundImage.Width;
this.Height = this.BackgroundImage.Height;
this.TransparencyKey = Color.FromArgb(0, 255, 0); //Contrast Color

这允许您基于图像创建表单,并使用透明度索引使表单看起来不是矩形。

【讨论】:

  • 不幸的是,如果表单的不透明度设置为 100% 以外的任何值(显然 .NET 应用不透明度效果,然后应用透明蒙版),这将不起作用。
  • 嗯,它确实有效,但是你必须弄清楚在不透明效果之后透明颜色会是什么。
  • 在.NET中实现不规则表单的最简单方法codeproject.com/Tips/149249/…
【解决方案2】:

@Geoff 在 winforms 中显示了正确的方式。

但是如果您打算使用 WPF 而不是 Winforms,那么 WPF(.NET3.0+) 提供了非常灵活的方法来创建任意形状的自定义窗口。也可以看看这篇文章http://www.codeproject.com/KB/WPF/wpfpopup.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-22
    相关资源
    最近更新 更多