码迷,mamicode.com
首页 > Windows程序 > 详细

winform中真正的透明label

时间:2015-05-01 12:00:16      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:

winform中的透明都是假透明,只是将背景色设置为父级容器的背景色。所以从网上找到这个真正透明的label。

 

 

 1 public partial class transparentLabel : UserControl
 2     {
 3         public transparentLabel()
 4         {
 5             InitializeComponent();
 6             SetStyle(ControlStyles.SupportsTransparentBackColor
 7               | ControlStyles.UserPaint
 8               | ControlStyles.AllPaintingInWmPaint
 9               | ControlStyles.Opaque, true);
10             this.BackColor = Color.Transparent;
11         }
12         protected override CreateParams CreateParams
13         {
14             get
15             {
16                 CreateParams cp = base.CreateParams;
17                 cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT 
18                 return cp;
19             }
20 
21         }
22     }

 

winform中真正的透明label

标签:

原文地址:http://www.cnblogs.com/strongZZ/p/4470488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!