c# winform 自动关闭messagebox 模拟回车
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; namespace WindowsApplication1
{
public partial class AutoDeleteMessageBox : Form
{
[DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); public const int WM_CLOSE = 0x10; public AutoDeleteMessageBox()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
StartKiller();
MessageBox.Show("3秒钟后自动关闭MessageBox窗口", "MessageBox");
} private void StartKiller()
{
Timer timer = new Timer();
timer.Interval = ; //3秒启动
timer.Tick += new EventHandler(Timer_Tick);
timer.Start();
} private void Timer_Tick(object sender, EventArgs e)
{
KillMessageBox();
//停止Timer
((Timer)sender).Stop();
} private void KillMessageBox()
{
//按照MessageBox的标题,找到MessageBox的窗口
IntPtr ptr = FindWindow(null, "MessageBox");
if (ptr != IntPtr.Zero)
{
//找到则关闭MessageBox窗口
PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
}
}
}
c# winform 自动关闭messagebox 模拟回车的更多相关文章
- 自动关闭AfxMessageBox对话框―模拟"回车" VC
有的时候,在程序里面调用太多的AfxMessageBox(非调试用),弹出的对话框要手动关闭,时间一长就感觉很繁琐.于是上网找了一些资料,发现有一个很简单的实现AfxMessageBox对话框自动关闭 ...
- C# WinForm 中 MessageBox的使用详解
1.C# WinForm 中 MessageBox的使用详解:http://www.cnblogs.com/bq-blog/archive/2012/07/27/2611810.html
- 定时自动关闭messagebox
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- c#自动关闭 MessageBox 弹出的窗口
我们都知道,MessageBox弹出的窗口是模式窗口,模式窗口会自动阻塞父线程的.所以如果有以下代码: MessageBox.Show("内容',"标题"); 则只有关闭 ...
- winform中webBrowser模拟网页操作中遇到的问题
我们通过网页上传一些特殊数据的时候,由于必填项众多,数量量大的时候,会发现工作相当繁琐,前段时间做了一个winform内嵌webBrowser模拟网页上传文档的小工具,发现了许多问题,总结一下: 先说 ...
- 延时并自动关闭MessageBox
信息提示框(MessageBox)是微软NET自带的一个用于弹出警告.错误或者讯息一类的“模式”对话框.此类对话框一旦开启,则后台窗体无法再被激活(除非当前的MessageBox被点击或者关闭取消). ...
- winform中messageBox七个参数的使用(转载)
private void button1_Click(object sender, EventArgs e) { MessageBox.Show(" 1 个参数 ”); } private ...
- winform 关于Messagebox自动定时关闭
添加一个类库MessageBoxTimeOut public class MessageBoxTimeOut { private string _caption; public void Show(s ...
- C# winform OpenFileDialog MessageBox
1.弹出窗体选择本地文件-OpenFileDialog OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Tit ...
随机推荐
- atcoder之A Great Alchemist
C - A Great Alchemist Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Problem Carol i ...
- Mac - 使用php环境
按下shift + Command + G ,输入以下php(www)路径 /Library/WebServer/Documents 打开终端,输入以下命令打开环境 sudo apachectl s ...
- jmeter 非GUI执行测试,导入jtl文件没有响应数据出来办法
jemter 官方也一直强调要在非GUI下执行 Run your JMeter test in command-line non-GUI mode as 在linux下执行jmeter压力测试,生成j ...
- CPD轮播广告库的简单算法
在广告的领域中,有一种广告形式,采用的是CPD的售卖模式,为了对流量进行拆分,媒体方会对广告位进行轮播拆分.比如一个广告位,被拆成了10轮播,那么在广告主来预订广告位的时候,这个时候就可以告诉广告主, ...
- php教程之php空白页的原因及解决方法
php中出现空白页的原因及解决方法汇总. 很多程序员在进行php开发的时候都遇到过出现空白页的请,综合分析来说,在php编程中出现空白页面可能是由以下几个原因造成的: 1.逻辑错误逻辑错误是最难排除的 ...
- win常用
//base.Invoke((MethodInvoker)delegate() //{ // this.Close(); //});
- CCNotificationCenter(一)
const std::string testsName[MAX_COUNT] = { "Bug-350", "Bug-422", "Bug-458&q ...
- angular学习笔记(十四)-$watch(2)
下面来看一个$watch的比较复杂的例子: 还是回到http://www.cnblogs.com/liulangmao/p/3700919.html一开始讲的购物车例子, 给它添加一个计算总价和折扣的 ...
- 每日英语:China's New Anti-Graft Website: A Tale of Tigers, Flies and Bath Tubs
With considerable fanfare, China's anti-graft squad has rolled out a brand new website in the ongoin ...
- cocos2d-x中几种存储数据的方式
说明:本文所论述内容均基于cocos2dx 3.0 版本. 1.UserDefault 它是cocos2d-x用来存取基本数据类型用的.保存为XML文件格式. 查看CCUserDefault文件,可以 ...