在CodeProject上看到这么一个美丽的东西, 效果如下图, 很棒吧~

Vista-Like 的玻璃按钮 Using GDI+

文章和代码下载地址是: http://www.codeproject.com/cs/miscctrl/glassbutton.asp

原来一直不知道如何让一个Control半透明, 在网上看到的方法大多不太实用, 看了这个GlassButton的代码后, 恍然发现只要这么三行代码:

            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);

            SetStyle(ControlStyles.Opaque, false);

            base.BackColor = Color.Transparent;

然后就可以任意在OnPaint里面用半透明的颜色画了......

相关文章:

  • 2021-06-19
  • 2021-07-27
  • 2022-12-23
  • 2021-06-07
  • 2021-10-01
  • 2021-06-25
猜你喜欢
  • 2021-12-15
  • 2021-10-22
  • 2021-12-21
  • 2021-12-25
  • 2021-10-30
  • 2021-09-23
  • 2021-06-12
相关资源
相似解决方案