大家帮我改改代码,要实现的功能是这样的:打开程序自动阻止关机、重启动作,点击X关闭后缩小到任务栏,这个已经实现,但是还不能阻止关机,大家帮我改一下代码~~~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 示例
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (this.Visible)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
} this.Visible = false;
} private void button1_Click(object sender, EventArgs e)//缩小到任务栏按钮
{
//Application.Exit();
//Form fm = new Form();
//fm.Dispose();
this.Visible = false;
} private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)//显示窗体
{
this.Visible = true;
} private void 完全退出ToolStripMenuItem_Click(object sender, EventArgs e)//退出菜单
{
this.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 示例
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (this.Visible)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
} this.Visible = false;
} private void button1_Click(object sender, EventArgs e)//缩小到任务栏按钮
{
//Application.Exit();
//Form fm = new Form();
//fm.Dispose();
this.Visible = false;
} private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)//显示窗体
{
this.Visible = true;
} private void 完全退出ToolStripMenuItem_Click(object sender, EventArgs e)//退出菜单
{
this.Close();
}
}
}
解决方案 »
- 学完C#《设计模式》,老是要求用5种模式做一个实例。求高手帮助
- 手持设备上,软件运行慢怎么解决?
- (C#-Winform)在未创建句柄之前,不能调用控件的Invoke和BeginInvoke
- 如何把代码针对SQLSERVER的代码改成针对ACCESS的?
- treeview控件只显示,提交
- C#-AutoCAD的问题!急!
- 怎样取得 DataGrid 中 CurrentCell 里的值啊 - 急,在线等
- c# 的form 中如何知道当前汉文输入法是否打开?
- 如何将某区域的颜色变得透明,就是阴影效果
- 请教 HttpWebResponse 的销毁问题
- .net 制作安装包
- 求助~c# 中的tabControl中的标签如何居右显示
你要让别人写代码就写代码,还说这么好听让别人帮你改改!