有一段vb.net的代码,你看看:
Public Const SC_CLOSE As Integer = 61536
Public Const WM_SYSCOMMAND As Integer = 274
Private closeBZ As Boolean = False
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then
If MsgBox("您真的要退出吗?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.Dispose(True)
Application.Exit()
closeBZ = True
End If
End If
MyBase.WndProc(m)End Sub
Public Const SC_CLOSE As Integer = 61536
Public Const WM_SYSCOMMAND As Integer = 274
Private closeBZ As Boolean = False
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then
If MsgBox("您真的要退出吗?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.Dispose(True)
Application.Exit()
closeBZ = True
End If
End If
MyBase.WndProc(m)End Sub
解决方案 »
- 那个高手用微软做过语音的请指导
- .net 同时删除文件和文件夹
- (高难!)关于能过互联网上传文件\多个不同视频站站访问管理,有这方面经验的请进?顶都有分...
- 有关系列化---收集帖(答者有分)
- asp.net 数据写入word表格
- wcf 用户登陆问题 网页程序
- 刚学.net,请兄弟姐妹们推荐几个.net网站,最好是中文的。
- 怎样将添加的数据在DataGridView中显示
- 紧急求助:用vs.net制作安装程序,怎样获取用户选择的安装路径,并根据路径更新相应的XML配置文件(在线等候)
- 千分相送,求解以下五个问题,如有答案,本人感激不尽!(1000分)
- C#中如何使用加了密码的ACCESS数据库?
- 请问如何从架构生成类?
{
if (MessageBox.Show(this,"确定要关闭吗?","信息提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Question)!=DialogResult.OK)
{
e.Cancel=true;
}
}
{
DialogResult result=new DialogResult();
result=MessageBox.Show("真的要退出吗?","MyWord",MessageBoxButtons.OKCancel);
if(result==DialogResult.OK)
{
Application.Exit();
}
else
{
e.Cancel=true;
}
}
在窗体的Closing事件中添加判断,如下:private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(MessageBox.Show("您确定退出本系统吗?","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
{
e.Cancel=false;
}
else
{
e.Cancel=true;
}
} freeboy0002这位仁兄你笔误了!e.Cancel=true是取消关闭事件,而不能关闭窗体。 :)