MessageBox.Show has forms like MessageBox.Show( ownerWindow, .... ).

What do I gain by assigning a owner window?

解决方案

A message box is a modal form, which means that its parent window is disabled until the message box is dismissed.

If a Show() overload is called that does not take an owner identifier, then a parent form is usually chosen automatically. I can't find anything in the documentation that describes how that form is chosen, but my experience is that if the message box is displayed inside the GUI thread (i.e., the main thread, or message pump thread), then the active window for that thread is chosen as the parent.

Other threads may create message boxes with no parent form. This could be a bad situation, because it could sit behind the active window, and the user will not even know it is there until they close the program. To avoid this, you could pass the handle of the application's main window to the Show method, which will disable that window for the duration of the message box.

ADDED: I've been thinking about this and now I'm not so sure. The snippet from reflector that you gave below makes me think that maybe the thread doesn't matter. (I did say that I couldn't find anything in the documentation!)

I'd have to go back and look at the code to make sure, but I think the message boxes that I used to lose behind the main form may have actually been custom message box forms, in which case my experience is faulty, and you never ever have to supply a parent form parameter.

Sorry for the confusion.

My recommendation now is to never supply this parameter unless you need something other than the active window to be the main form.

python messagebox一定要指定父窗体吗,为什么要使用的MessageBox.show一个所有者窗口?...相关推荐

  1. 父窗体中弹出新窗体,然后获取弹出窗体的返回值。

    通过弹出的窗体向父窗体传递参数 通过window.returnvalue向打开对话框的窗口返回信息,当然也可以是对象.例如:  test4.htm  ===================  < ...

  2. 如何:创建 MDI 父窗体、子窗体、确定活动的 MDI 子窗体

    Microsoft Visual Studio 2008/.NET Framework 3.5 Windows 窗体编程 如何:创建 MDI 父窗体 多文档界面 (MDI) 应用程序的基础是 MDI ...

  3. 从子窗体传递数据给父窗体

    弹出窗口刷新它的父页面后.出现不重新发送信息,则无法刷新网页 2005-09-29 13:49 黄玮璘 很简单的解决方法 在.NET里头 默认有POSTBACK的控件存在 当页面回传的时候 后台会根据 ...

  4. QT5 获取窗口、系统屏幕大小尺寸信息,Qt 获取控件位置坐标,屏幕坐标,相对父窗体坐标

    一.QT5 获取窗口大小尺寸信息 QT窗口尺寸,窗口大小和大小改变引起的事件 QResizeEvent. //窗口左上角的位置(含边框)qDebug() << this->frame ...

  5. Windows应用程序C#创建MDI父窗体和子窗体

    一:创建父窗体 1.创建 Windows 应用程序. 2.在"属性"窗口中,将 IsMDIContainer 属性设置为true. 这将该窗体指定为子窗口的MDI 容器. 3.设置 ...

  6. showdialog wpf 如何关闭_WPF用ShowDialog()弹出窗体时控制该窗体的显示位置,并传值回父窗体...

    原文:http://blog.csdn.net/kiss0622/article/details/5852153 方法一: 1.父窗口代码 Window1.xaml.cs private void B ...

  7. 如何用python读取文本中指定行的内容

    如何用python读取文本中指定行的内容 搜索资料 我来答 分享 新浪微博 QQ空间 浏览 5284 次 查看全文 http://www.taodudu.cc/news/show-64036.ht ...

  8. Python 获取list 中指定元素出现的次数

    Python 获取list 中指定元素出现的次数 使用list 的count 方法 list_a = [1, 2, 3, 1, 4, 5, 1] print("1 出现的次数: %d&quo ...

  9. python删除指定位置的字符串_python去除区域 python删除字符串中指定位置字符

    python删除字符串中指定位置字符 原程序是这样的: ser = serial.Serial("/dev/ttyAMA0", 9600) def main字符串的话,你可以把他当 ...

最新文章

  1. Tungsten Fabric SDN — 社区贡献
  2. Javascript中计算脚本运行的时间
  3. oracle 11查询sid,oracle 11g 更改sid和dbname
  4. (三十三)设计模式之混合模式
  5. mysql cluster双机_GitHub - sophys/mysqlha: 博客“Mysql-cluster数据库集群双机HA研究”测试代码...
  6. java面向对象编程思想_Java面向对象编程思想
  7. PLSQL查询字段为科学计数法,修正显示
  8. MySQL在Windows 环境中的安装
  9. 管家婆服务器支持者打不开,管家婆软件数据问题使用技巧
  10. jupyter notebook如何选择conda环境
  11. Gartner最新洞见:数据分析将是改变“游戏规则”的技术、企业的中台需要可组装的架构
  12. JMeter分布式负载测试(吞吐量控制器)
  13. 我的第一个字典-Dictionary
  14. jsp的mysql数据库分页查询_Jsp如何实现分页功能(使用MySQL数据库)
  15. python万年历代码带解释_Python 万年历代码简单示例
  16. 上海python暑假培训班
  17. Codeforces Round #393 (Div. 2) B. Frodo and pillows
  18. 你真的打算凑合过完这一生吗(转)
  19. 【iccv2021】Vision-Language Transformer and Query Generation for Referring Segmentation
  20. 带宽与码元的关系_数据速率、载波频率和带宽的关系

热门文章

  1. 如何在窗体之间通讯的几种方法 ? VB.NET方案
  2. SQLite 性能优化
  3. about Ghost Solution Suite 2.5
  4. 最长回文子串python_最长回文子串(Python)
  5. 【学习笔记】JS进阶语法一document对象
  6. 【ABAP妙用】复制ALV之负号提前
  7. SAP日志log:SLG0,SLG1
  8. Smart Form中打印图标或符号
  9. 解决归档出错,ORA-00257: archiver error. Connect internal only, until freed.
  10. Java9新功能之HTTP2和REPL