winform最小化及关闭提示
public PrintService()
{
InitializeComponent();
this.WindowState = FormWindowState.Minimized;
} private void PrintService_Load(object sender, EventArgs e)
{
//初始化是不可见的
//notifyIcon.Visible = false;
} protected override void OnClosing(CancelEventArgs e)
{
if (MessageBox.Show("是否确认关闭打印服务?", "退出确认", MessageBoxButtons.OKCancel) != DialogResult.OK)
{
e.Cancel = true;
}
base.OnClosing(e);
}
消息提示优化
* 参考:http://www.cnblogs.com/ManchesterUnitedFootballClub/p/4596465.html Winfrom 提示消息框公共类
* http://www.cnblogs.com/wuhuacong/archive/2011/11/22/2259128.html Winform开发框架之对话框样式同化
http://www.aichengxu.com/other/1850478.htm DevExpress MessageBox 弹出框 底层类
前台调用:
//图一的前台调用
MessageBox.Show("测试", "标题", MessageBoxButtons.OK);
//图二的前台调用
Functionjsj.ShowMsg("测试", Functionjsj.MsgType.OK);
说明: Functionjsj 为自定义类:下有三种类型的输出:
Functionjsj.ShowMsg(消息, 枚举类型);Functionjsj.ShowMsg(消息, 标题, 枚举类型);Functionjsj.ShowMsgBox(消息, 标题, 枚举类型);
底层类:
#region DevExpress MessageBox 弹出框 #region 枚举弹出类型
public enum MsgType {
/// <summary>
/// 提示
/// </summary>
OK = ,
/// <summary>
/// 警告
/// </summary>
Warning = ,
/// <summary>
/// 询问
/// </summary>
Question = ,
/// <summary>
/// 错误
/// </summary>
Exception = ,
/// <summary>
/// 是/否/取消
/// </summary>
YesNoCancel = ,
/// <summary>
/// 是/否
/// </summary>
YesNo =
}
#endregion /// <summary>
/// 显示消息
/// </summary>
/// <param name="msg">消息</param>
/// <param name="ie">消息类型</param>
/// <returns>需要用户作出选择时,返回YES or NO,否则返回,ok,cancel等</returns>
public static System.Windows.Forms.DialogResult ShowMsg(string msg, MsgType msgType)
{
switch (msgType)
{
case MsgType.OK:
return ShowMsg(msg, "信息", MsgType.OK);
case MsgType.Question:
return ShowMsg(msg, "确认", MsgType.Question);
case MsgType.Warning:
return ShowMsg(msg, "警告", MsgType.Warning);
case MsgType.Exception:
Exception(msg);
return System.Windows.Forms.DialogResult.OK;
case MsgType.YesNoCancel:
return ShowMsg(msg, "请选择", MsgType.YesNoCancel);
case MsgType.YesNo:
return ShowMsg(msg, "请选择", MsgType.YesNo);
default:
return System.Windows.Forms.DialogResult.Cancel;
}
} /// <summary>
/// 显示消息
/// </summary>
/// <param name="msg">消息</param>
/// <param name="caption">标题 系统会自动加上一些信息</param>
/// <param name="msgType">消息类型</param>
/// <returns>需要用户作出选择时,返回YES or NO,否则返回,ok,cancel等</returns>
public static System.Windows.Forms.DialogResult ShowMsg(string msg, string caption, MsgType msgType)
{
switch (msgType)
{
case MsgType.OK:
return ShowMsgBox(msg, caption, msgType);
case MsgType.Question:
return ShowMsgBox(msg, caption, msgType);
case MsgType.Warning:
return ShowMsgBox(msg, caption, msgType);
case MsgType.Exception:
Exception(msg);
return System.Windows.Forms.DialogResult.OK;
case MsgType.YesNoCancel:
return ShowMsgBox(msg, caption, msgType);
case MsgType.YesNo:
return ShowMsgBox(msg, caption, msgType);
default:
return System.Windows.Forms.DialogResult.Cancel;
}
} /// <summary>
/// 显示消息
/// </summary>
/// <param name="msg">消息</param>
/// <param name="catpion">标题</param>
/// <param name="msgType">消息类型</param>
/// <returns>需要用户作出选择时,返回YES or NO,否则返回,ok,cancel等</returns>
public static System.Windows.Forms.DialogResult ShowMsgBox(string msg, string catpion, MsgType msgType)
{
switch (msgType)
{
case MsgType.OK:
return Show(msg, catpion, System.Windows.Forms.MessageBoxButtons.OK);
case MsgType.Question:
return Question(msg, catpion, System.Windows.Forms.MessageBoxButtons.OKCancel, MessageBoxDefaultButton.Button2);
case MsgType.Warning:
return Warning(msg, catpion, System.Windows.Forms.MessageBoxButtons.OK);
case MsgType.Exception:
Exception(msg);
return System.Windows.Forms.DialogResult.OK;
case MsgType.YesNoCancel:
return Information(msg, catpion, System.Windows.Forms.MessageBoxButtons.YesNoCancel, MessageBoxDefaultButton.Button3);
case MsgType.YesNo:
return Information(msg, catpion, System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
default:
return System.Windows.Forms.DialogResult.Cancel;
}
} /// <summary>
/// 显示消息
/// </summary>
/// <param name="msg">消息</param>
/// <param name="ie">消息类型</param>
/// <returns>需要用户作出选择时,返回YES or NO,否则返回,ok,cancel等</returns>
public static System.Windows.Forms.DialogResult ShowMsg(IWin32Window owner, string msg, MsgType msgType)
{
switch (msgType)
{
case MsgType.OK:
return Show(msg, "信息", System.Windows.Forms.MessageBoxButtons.OK);
case MsgType.Question:
return Question(msg, "确认", System.Windows.Forms.MessageBoxButtons.OKCancel, MessageBoxDefaultButton.Button2);
case MsgType.Warning:
return Warning(msg, "警告", System.Windows.Forms.MessageBoxButtons.OK);
case MsgType.Exception:
Exception(msg);
return System.Windows.Forms.DialogResult.OK;
case MsgType.YesNoCancel:
return Information(msg, "请选择", System.Windows.Forms.MessageBoxButtons.YesNoCancel, MessageBoxDefaultButton.Button3);
default:
return System.Windows.Forms.DialogResult.Cancel;
}
} #region Show
public static DialogResult Show(string text)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text);
} public static DialogResult Show(string text, string caption)
{ return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption);
} public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, MessageBoxIcon.Information);
} public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(owner, text, caption, buttons, MessageBoxIcon.Information);
} public static DialogResult Show(string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, MessageBoxIcon icon)
{ return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, icon);
} public static DialogResult Show(IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, MessageBoxIcon icon)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(owner, text, caption, buttons, icon);
}
#endregion #region Information public static DialogResult Information(string message)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(message, " 消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
} public static DialogResult Information(string message, string caption)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
} public static DialogResult Information(string message, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(message, caption, buttons, MessageBoxIcon.Information);
}
public static DialogResult Information(string message, string caption, MessageBoxButtons buttons, MessageBoxDefaultButton defButton)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(message, caption, buttons, MessageBoxIcon.Information, defButton);
}
#endregion #region Question public static DialogResult Question(string text)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, "疑问", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
public static DialogResult Question(string text, string caption)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Question);
}
public static DialogResult Question(string text, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, MessageBoxIcon.Question);
} public static DialogResult Question(string text, string caption, MessageBoxButtons buttons, MessageBoxDefaultButton defButton)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, MessageBoxIcon.Question, defButton);
} #endregion #region Warning
public static DialogResult Warning(string text)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static DialogResult Warning(string text, string caption)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static DialogResult Warning(string text, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, MessageBoxIcon.Warning);
}
#endregion #region Exception
public static DialogResult Exception(string text)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static DialogResult Exception(string text, string caption)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static DialogResult Exception(string text, string caption, MessageBoxButtons buttons)
{
return DevExpress.XtraEditors.XtraMessageBox.Show(text, caption, buttons, MessageBoxIcon.Error);
}
#endregion #endregion
winform最小化及关闭提示的更多相关文章
- Winform 基础二 最小化 最大化 关闭 点击任务栏隐藏显示 点击鼠标左键移动窗体
一 最大化 二 最小化 三 关闭 四 点击任务栏隐藏显示 五 点击鼠标左键移动窗体 六 阴影效果鼠标左键移动窗口 #region UI设置 最大化.最小化.关闭.鼠标移动窗口.点击任务栏切换窗口 th ...
- jquery定时滑出可最小化的底部提示层
效果预览:http://keleyi.com/keleyi/phtml/jqtexiao/index.htm当打开页面或者刷新页面后等待两秒钟,会在底部滑出可最小化的提示层.滑出层半透明,可关闭再现. ...
- JS实现漂亮的窗口拖拽效果(可改变大小、最大化、最小化、关闭)
转自<JS实现漂亮的窗口拖拽效果(可改变大小.最大化.最小化.关闭)>:http://www.jb51.net/article/73157.htm 这篇文章主要介绍了JS实现漂亮的窗口 ...
- Delphi模拟最小化恢复关闭按纽
https://yq.aliyun.com/wenji/96083 本文讲的是Delphi模拟最小化恢复关闭按纽, 我们做多文档应用程序开发时,如果在主From中指定mainMenu时,在主菜单上右角 ...
- delphi -----(去掉窗口最大化,最小化、关闭),主窗口,和子窗口之间的设置
一.去掉窗口最大化,最小化.关闭 borderIcons:biSystemMenu:false borderStyle:bsSizeable 二.主子窗口 主main: //调用子窗体procedur ...
- [WinForm]最小化到系统托盘,右键退出
1.拉出一个notifyIcon1到用户界面,也可以NEW一个 2.拉出一个ContextMenuStrip控件,命名为mymenu,集合中增加退出 3.notifyIcon1的属性ContextMe ...
- Winform 最小化双击显示,最小化右键退出。退出
WinForm 之 窗口最小化到托盘及右键图标显示菜单 Form最小化是指整个Form都缩小到任务栏上,但是窗体以Form的标题栏形式显示在任务栏上, 若是想让Form以Icon的形式显示在任务栏右下 ...
- winform最小化及添加右键
private void PrintService_SizeChanged(object sender, EventArgs e) { if (this.WindowState == FormWind ...
- WinForm最小化到托盘以及托盘右键菜单
首先,先拖一个NotifyIcon到主窗体,然后设置NotifyIcon的图标,不然等下最小化后,都找不到那个程序了,还有那个Text也是,不写名字,就默认是NotifyIcon了..如下图: 然后双 ...
随机推荐
- JS解决URL传递参数中文乱码问题
function getUrlParam(name){ // 用该属性获取页面 URL 地址从问号 (?) 开始的 URL(查询部分) var url = window.location.search ...
- UltraISO(软碟通)制作安装Ubuntu系统的U盘安装盘
1.开UltraISO(软碟通),加载要写入U盘的iso文件,注意,要求软碟通的版本是9.3以上的.如下图: 2.点击“启动光盘.写入硬盘映像: 3.开启个写入硬盘映像的窗口,硬盘驱动器那一项看清楚是 ...
- dotnet若干说明图片
- 网页中输出漂亮格式的Php数组神器
写网页的时候经常需要在页面中打印数组,但格式特别难看,看看一个html神器吧<pre>标签,能非常标准的显示数组格式 使用的时候只需要这样打印你的数组就OK了,太好用了,神器! 只需要两句 ...
- python利用opencv去除水印方法
OpenCV(Open Source Computer Vision Library)是一个跨平台计算机视觉库,实现了图像处理和计算机视觉方面的很多通用算法 在python中可以利用opencv来去除 ...
- Shadow Map 原理和改进 【转】
http://blog.csdn.net/ronintao/article/details/51649664 参考 1.Common Techniques to Improve Shadow Dept ...
- hue启用ldap
[desktop] [[auth]] …… …… backend=desktop.auth.backend.LdapBackend .….. http://gethue.com/ldap-or-pam ...
- Index 和 Type 的区别
原文: Index vs. Type By Adrien Grand 译者: fengchang 对于 ES 的新用户来说,有一个常见的问题:要存储一批新的数据时,应该在已有 index 里新建一个 ...
- JS 数字左补零函数
/* 左边自动补零 质朴长存法 by lifesinger */ function pad(num, n) { var len = num.toString().length; while(len & ...
- CF无法全屏怎么办
方法1:把桌面的分辨率调成800X600,然后运行CF就全屏了,接着再退出游戏,把桌面重新调回原来的分辨率. 方法2:在运行中输入regedit.可以打开打开注册表编辑器,定位到HKEY_LOCAL_ ...