WinForms and ShowDialog problem.

Posted by SchlaWiener on Stack Overflow See other posts from Stack Overflow or by SchlaWiener
Published on 2010-05-27T16:29:49Z Indexed on 2010/05/27 16:31 UTC
Read the original article Hit count: 417

Filed under:
|
|

I have a borderless WinForms app.

The main window creates other forms (simple dialogs where I can click yes or no) with ShowDialog(). Every created dialog is not visible in the taskbar, my app has only one taskbar entry that focuses my app (and if a dialog is open that one is focused). If I use ALT+TAB to cycle to all open windows I only see one entry, too.

However, If the dialog is created while my app doesn't have the focus (for example the user starts a long running task, starts to work on something else and while being in the background, my app shows a dialog "Task done...") and I want to go back to my app, things are getting strange.

  • If I click on the taskbar to focus my app, the main window is focused (not the dialog).
  • I can't use the main window (because there is still an open modal dialog).
  • Windows 7 ALT-TAB preview shows the Dialog while taskbar mouseover preview shows the main window (In normal behavior both show the dialog in front of the main window).
  • The only way to make my app usable again is to ALT-TAB to the entry and close the modal dialog.
  • If I use ALT-TAB only the dialog is brought to the front and the main window is still in the background

Is there a way to prevent that from happening? I know what to do, but most customers think the app crashed since the main window doesn't respond.

© Stack Overflow or respective owner

Related posts about winforms

Related posts about showdialog