winfrom 自动关闭 重新MessageBox.Show("Test");
复制代码 自动关闭
调用 AutoClosingMessageBox.Show("添加失败", "提示", 1000);
#region alert
public class AutoClosingMessageBox
{
System.Threading.Timer _timeoutTimer;
string _caption;
AutoClosingMessageBox(string text, string caption, int timeout)
{
_caption = caption;
_timeoutTimer = new System.Threading.Timer(OnTimerElapsed,
null, timeout, System.Threading.Timeout.Infinite);
MessageBox.Show(text, caption);
}
public static void Show(string text, string caption, int timeout)
{
new AutoClosingMessageBox(text, caption, timeout);
}
void OnTimerElapsed(object state)
{
IntPtr mbWnd = FindWindow(null, _caption);
if (mbWnd != IntPtr.Zero)
SendMessage(mbWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
_timeoutTimer.Dispose();
}
const int WM_CLOSE = 0x0010;
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
}
#endregion
winfrom 自动关闭 重新MessageBox.Show("Test");的更多相关文章
- C#自动弹出窗口并定时自动关闭
最近做个小项目,用到一个小功能:后台线程定时查询数据库,不符合条件的记录弹出消息提醒(在窗口最前面),并且过几秒钟再自动关闭弹出的窗口. 所以从网上找来资料,如下: WinForm 下实现一个自动关闭 ...
- 定时自动关闭messagebox
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- c#自动关闭 MessageBox 弹出的窗口
我们都知道,MessageBox弹出的窗口是模式窗口,模式窗口会自动阻塞父线程的.所以如果有以下代码: MessageBox.Show("内容',"标题"); 则只有关闭 ...
- WinForm中使MessageBox实现可以自动关闭功能
WinForm 下我们可以调用MessageBox.Show 来显示一个消息对话框,提示用户确认等操作.在有些应用中我们需要通过程序来自动关闭这个消息对话框而不是由用户点击确认按钮来关闭.然而.Net ...
- C# MessageBox自动关闭
本文以一个简单的小例子,介绍如何让MessageBox弹出的对话框,在几秒钟内自动关闭.特别是一些第三方插件(如:dll)弹出的对话框,最为适用.本文仅供学习分享使用,如有不足之处,还请指正. 概述 ...
- 设置MessageBox自动关闭
通过设置定时器,让定时器的Tick事件模拟往MessageBox发送一个Enter按钮代替用鼠标点击MessageBox上的确定按钮,来实现MessageBox的自动关闭,实现代码如下: System ...
- winform messagebox自动关闭
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- c# winform 自动关闭messagebox 模拟回车
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 延时并自动关闭MessageBox
信息提示框(MessageBox)是微软NET自带的一个用于弹出警告.错误或者讯息一类的“模式”对话框.此类对话框一旦开启,则后台窗体无法再被激活(除非当前的MessageBox被点击或者关闭取消). ...
随机推荐
- iOS-保存图片到相册
//保存 UIButton *saveBtn = [[UIButton alloc] init]; // saveBtn.frame = CGRectMake((screenWi ...
- JKD1.8新特性
1.Optional类 Optional是jdk1.8引入的类型,Optional是一个容器对象,它包括了我们需要的对象,使用isPresent方法判断所包 含对象是否为空,isPresent方法返回 ...
- ABC技术落地_成功带动lot物联网行业、金融科技行业、智能人才教育。
ABC技术:AI:Python神经网络和自然语言处理(NLP):C ++ 机器学习和神经网络:Java自然语言处理.搜索算法.神经网络:Lisp归纳逻辑项目和机器学习.Big Date:R.Pytho ...
- exchange 2010入门到精通
exchange 2010入门到精通 Exchange产品介绍和功能演示 Exchange是什么 目前最受欢迎企业级邮件服务器产品 市场占有率70%(2011数据) 微软消息协作平台中核心产品 Exc ...
- [Kevin英语情报局]那些年我们说过的中式英语
一. blonde hair 金色头发 grey hair 白头发 baijiu 白酒 white wine 白葡萄酒 I don't think it's right 我认为不正确 I'm chin ...
- ffmpeg学习笔记-Linux下编译Android动态库
Android平台要使用ffmpeg就需要编译生成动态库,这里采用Ubuntu编译Android动态库 文件准备 要编译生成Android需要以下文件 NDK ffmpeg源代码 NDK下载 NDK可 ...
- rpm 包安装调试缺少依赖无法安装的方法
今天在给龙芯中标机器安装360 10.0.2001.1 版本时 发现有依赖过不去. 因为依赖关系而调过软件包: browser360-cn-stable-10.0.2001.0-1.mips64el ...
- oracle——学习之路(select检索)
select语法: select [distinct|all] 列名 from 表名 [where] [group by] [having] [order ...
- oracle中Blob、Clob、Varchar之间的互相转换
以下是oracle中Blob.Clob.Varchar之间的互相转换(都是百度找的,亲测可用) Blob转Varchar2: CREATE OR REPLACE FUNCTION blob_to_va ...
- Double write Buffer的配置
InnoDB和XtraDB使用称为doublewrite缓冲区的特殊功能来提供数据损坏的强大保证.想法是在写入数据文件之前将数据写入主表空间中的顺序日志.如果发生部分页面写入(换句话说,写入损坏),I ...