Why use a owner window in MessageBox.Show?

前端 未结 8 1174
我寻月下人不归
我寻月下人不归 2020-12-14 17:31

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

What do I gain by assigning a owner window?

8条回答
  •  春和景丽
    2020-12-14 17:35

    Calling MessageBox.Show(frmMain,"a message","a title") adds the form TextDialog to the application's Application.OpenForms() forms collection, along-side the frmMain Main form itself. It remains after you close the Messagebox.

    I just discovered 14 of these when I called btnOK_Click() and set a breakpoint.

    When I called frmMain.Close() to close the main form, nothing happened. frmMain will not close until all 14 of the Application.OpenForms are closed as well or else you must call Application.Exit().

提交回复
热议问题