c#:
......
DialogResult PrtYesOrNo = MessageBox.Show("是否打印", "打印提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
......
不知道是否有自动关闭或定时关闭该消息框的实现方法。要实现的效果是在用户没有点击的情况下自动关闭该提示框以更加人性化。
......
DialogResult PrtYesOrNo = MessageBox.Show("是否打印", "打印提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
......
不知道是否有自动关闭或定时关闭该消息框的实现方法。要实现的效果是在用户没有点击的情况下自动关闭该提示框以更加人性化。
解决方案 »
- VS2008 如何实现最小化的窗体闪烁(象MSN来消息一样,而不弹出)
- 如何实现DropDownList里面的Items属性问题?
- XML怎样呈现树控件
- 编译提示“使用了未赋值局部变量FileLinkRS”,什么原因?
- 关于owc的问题?
- 如何将只读文件设为可写!
- 多线程问题:请各位高手看看本程序如何跃过无穷循环!!!--我所有分数只有70了!
- Ping服务器
- 在API中的常量的数字是多少啊比如,WH_KEYBOARD_LL中的
- To: CForce() 如何用C#写Ftp文件上传方面的程序?myEmail : [email protected] (肯定给分)
- C# 与 Excel通讯问题
- datagridview 的选择行顺序混乱?
最好自己编一个像MessageBox的窗体,就可以用timer控制了。
{
ThreadPool.QueueUserWorkItem(new WaitCallback(CloseMessageBox),
new CloseState(caption, timeout));
MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2);
} private void CloseMessageBox(object state)
{
CloseState closeState = state as CloseState; Thread.Sleep(closeState.Timeout);
IntPtr dlg = FindWindow(null, closeState.Caption); if (dlg != IntPtr.Zero)
{
IntPtr result;
EndDialog(dlg, out result);
}
} [DllImport("coredll.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll.dll")]
static extern bool EndDialog(IntPtr hDlg, out IntPtr nResult); private class CloseState
{
private int _Timeout;
public int Timeout
{
get
{
return _Timeout;
}
} private string _Caption;
public string Caption
{
get
{
return _Caption;
}
} public CloseState(string caption, int timeout)
{
_Timeout = timeout;
_Caption = caption;
}
} 使用时:
//提示框显示2秒钟后自动关闭
close_messageBox.ShowMessageBoxTimeout("发送完成!", "提示", 2000); 在winform下使用时,只需将coredll.dll改为win32.dll即可
可以了
但是现在感觉还是用模式窗口的效果要好一些,兼容性好且易控制,感谢各位,开始结帖散分了。