用SetLayeredWindowAttributes设置winform界面透明化
时间:2021-06-02 13:16:08
收藏:0
阅读:0
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace opacity { public partial class Form1 : Form { [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")] private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, int bAlpha, int dwFlags); public Form1() { InitializeComponent(); this.BackColor = Color.FromArgb(255, 255, 255);
this.Opacity = 0.5;
SetLayeredWindowAttributes(Handle, 0xffffff, 0, 1); } } }
评论(0)