Search code examples
c#winformsmodal-dialogshowdialog

DialogResult.Cancel on Form.ShowDialog() when switching to Desktop


I am trying to show a UI (WinForms) via result = new Form().ShowDialog(). The dialog pops up, works as expected but when i press Windows + D to tab away, the result immediately returns DialogResult.Cancel. Is there any way to keep the Form open when i am switching to desktop?

If there are any more questions or if it is unclear, please ask.

Best regards


Solution

  • I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show() instead of Form.ShowDialog() and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog().