界面
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsICM38FdsYkRGZkRG9lcvx2bjxiNx8VZ6l2cs0TPn10dZpmT1EEVOBDOsJGcohVYsR2MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLxQzMzMjMzcTM3ATMxkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
代码
private void OK_btn_Click(object sender, EventArgs e)//验证通过关闭窗体
{
string select = "SELECT * FROM log_in where username='" + Form1.name + "'and password='" + Pawss_txt.Text + "'";
int count = GMManage.SqlServerRecordCount(select);//返回符合的结果数量
if (count > 0)
{
this.Close();
}
else
{
MessageBox.Show("密码错误");
}
}
private void Lock_Load(object sender, EventArgs e)
{
CloseButtonEnable();
//不显示在任务栏中
this.ShowInTaskbar = false;
}
[DllImport("user32.dll")]
internal static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
[DllImport("user32.dll")]
internal static extern int GetMenuItemCount(IntPtr hMenu);
[DllImport("user32.dll")]
internal static extern int RemoveMenu(IntPtr hMenu, int uPosition, int uFlags);
/// <summary>
/// 窗体的关闭按钮失效
/// </summary>
protected void CloseButtonEnable()
{
// 默认窗口去除关闭按钮
const int MF_BYPOSITION = 0x00000400;
IntPtr hWindow = this.Handle;
IntPtr hMenu = GetSystemMenu(hWindow, false);
int count = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, count - 1, MF_BYPOSITION);
RemoveMenu(hMenu, count - 2, MF_BYPOSITION);
}