public partial class Form1 : Form
public Form1
InitializeComponent;
private void button1_Click(object sender, EventArgs e)
***.Show(Text, Caption, 1000);
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);
***.Show(text, caption);
【C# ***.Show怎么设置3秒后 自动关闭?】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 != ***.Zero)
SendMessage(mbWnd, WM_CLOSE, ***.Zero, ***.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.***.CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
以上关于本文的内容,仅作参考!温馨提示:如遇专业性较强的问题(如:疾病、健康、理财等),还请咨询专业人士给予相关指导!
「辽宁龙网」www.liaoninglong.com小编还为您精选了以下内容,希望对您有所帮助:- 狗狗眼屎多怎么回事啊
- 小狗眼屎多怎么处理方法
- 狗狗指甲怎么剪多少
- 狗子怎么会吐
- 分手闹的很僵怎么挽回
- 《炉石传说》中,为什么不把末日预言者设置为「无法通过特殊手段召唤」?
- 成都大学新任书记上任,你怎么看?
- 跑步前脚掌疼怎么办 怎么跑步才正确
- 生育情况怎么填写
- 运动后肌肉酸痛怎么办 运动后要这样放松身体