I have a Form A that launches Form B as modal dialog. Form B then launches Form C. The requirement is that Form C should remain on top even though if user closes Form B. In order to achieve that I have made Form A as parent for Form C and launching it as non-modal. So far so good, If user closes Form B, Form C still remain visible. Problem is in some cases user can launch a non-modal dialog (Form D) from Form B. In that case I still want to have Form C available but with current scheme its get blocked until user closes Form D. Any suggestion on how to accomplish it.
Asked
Active
Viewed 440 times
2
-
Modal dialogs block the main thread so to achieve this you can run your C form on another thread. – VahidNaderi Nov 29 '13 at 19:56
-
@VahidND You have to run all UI elements from the UI thread in Windows. – Szymon Nov 29 '13 at 20:12
-
This just sounds like dialog abuse. Dialogs suck, they should only be used to solve [this problem](http://stackoverflow.com/a/5183623/17034). – Hans Passant Nov 29 '13 at 20:18
-
@Hans what are you suggesting to use here then? – crazy novice Nov 29 '13 at 20:24
-
2Use dialogs only when you need them. Avoid confounding the user by having arbitrarily disabled windows and strange Z-order problems. Programs that you use everyday on your own machine don't work like that either. Re-think your UI model. – Hans Passant Nov 29 '13 at 20:33
-
Unfortunately this UI model was built way before i started. At this point, this product has hundreds of forms with 20000+ customers base. I am trying to figure out a solution within pre-defined constraints :) – crazy novice Nov 29 '13 at 20:42
-
@Szymon what do you mean by "you **have to** run all ....", can't we just have an independent from in an app monitoring something in real time or something else? – VahidNaderi Nov 29 '13 at 20:46
-
@VahidND You can start your form from any thread you want but you have to invoke it on the UI thread. – Szymon Nov 29 '13 at 21:16
1 Answers
1
I don't think you can. From MSDN:
A modal form or dialog box must be closed or hidden before you can continue working with the rest of the application.
That's the nature of the modal dialogs that they block. You generally use them to force the user to take some acion in the modal window.

Szymon
- 42,577
- 16
- 96
- 114