110,534
社区成员
发帖
与我相关
我的任务
分享
public partial class Form7 : Form
{
public Form7() {
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.Location = Point.Empty;
this.Size = Screen.PrimaryScreen.Bounds.Size;
}
private void Form7_Load(object sender, EventArgs e) {
this.SetBackground();
}
private void SetBackground() {
Bitmap bmp = new Bitmap(
Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height
);
using (Graphics g = Graphics.FromImage(bmp)) {
g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
using (SolidBrush sb = new SolidBrush(Color.FromArgb(125, 0, 0, 0))) {
g.FillRectangle(sb, 0, 0, bmp.Width, bmp.Height);
}
this.BackgroundImage = bmp;
}
}
}
public Form7() {
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.Location = Point.Empty;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.BackColor = Color.Red;//把红色掏空
this.TransparencyKey = this.BackColor;
}
private void Form7_Load(object sender, EventArgs e) {
Form frm = new Form();//遮罩窗体
frm.FormBorderStyle = FormBorderStyle.None;
frm.Location = Point.Empty;
frm.Size = this.Size;
frm.Opacity = 0.5;//半透明
frm.BackColor = Color.Black;
frm.Show();
this.Owner = frm;//显示在遮罩之上
}