不规则形状的Windows窗体(C#)

Mat*_*ías 18 .net c# winforms

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

Geo*_*off 29

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
Run Code Online (Sandbox Code Playgroud)

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

  • 嗯,它确实有效,但你必须弄清楚不透明效果后的透明度颜色. (3认同)

Job*_*Joy 7

@Geoff在winforms中展示了正确的方式.

但是如果您计划使用WPF而不是Winforms,那么WPF(.NET3.0 +)提供了非常灵活的方法来创建anyshape自定义窗口.查看本文也是http://www.codeproject.com/KB/WPF/wpfpopup.aspx