C#编程编写锁屏程序
发布网友
发布时间:2022-05-06 07:17
我来回答
共1个回答
热心网友
时间:2022-06-29 00:00
新建一个窗体,将MaximizeBox,MinimizeBox属性设置为False(意思就是将最大化,最小化按钮屏蔽掉)
在这个窗体的Closeing事件里e.Cancel = true(意思就是叫关闭按钮失灵)
还有一个就是叫这个窗体加载的是后就最大化将属性WindoeState更改为Maximized
下面是我用2005写的一个锁屏程序:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace KTV
{
/// <summary>
/// 挂起
/// </summary>
public partial class FrmGuaQi : Form
{
private string Pwd;
private bool bl = true;
public FrmGuaQi()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnGuanqi_Click(object sender, EventArgs e)
{
if (this.btnGuanqi.Text == "挂起")
{
this.Pwd = this.txtPwd.Text;
this.btnGuanqi.Text = "解除";
this.txtPwd.Clear();
}
else
{
if (this.Pwd == this.txtPwd.Text)
{
bl = false;
this.Close();
}
else
{
MessageBox.Show("密码不正确","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
private void FrmGuaQi_FormClosing(object sender, FormClosingEventArgs e)
{
// 屏蔽Alt+F4关闭
e.Cancel = bl ;
}
private void FrmGuaQi_Load(object sender, EventArgs e)
{
Common.ApplySkin(mySkin, this);
}
}
}