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     }

 

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2021-04-15
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案