I have a Dialog A and I want it to load a second dialog B which is modeless and stays along side A throughout. Dialog A may then launch a modal dialog C. But when C is present I want B to be usable. I would have fixed this with pretranslate message in A in a C++ application but what is the approach in C#.
+3
A:
When you launch Dialog C, launch it using yourFormVariable.Show()
instead of yourFormVariable.ShowDialog()
.
Form form1 = new Form();
Form form2 = new Form();
form1.Show();
form2.Show();
This will allow both forms to be active and usable by the user, whereas in the following code:
Form form1 = new Form();
Form form2 = new Form();
form1.Show();
form2.ShowDialog();
the user will have to close form2 before they can continue to use form1 again.
Note that there is no such thing as a modal dialog that allows the previous forms to be usable - a modal dialog by definition is one that the user has to interact with and close before continuing.
Andy Shellam
2010-03-23 08:40:13
I am aware that making C modeless would work, but I need the other dialog to respond, it may have text that aids the user to use dialog C. In effect, if I wanted a custom help system that is a buddy window, how do I let the user work with it. I know that Windows uses a separate process to launch help and those wizards, but I believe there should be no technical block to making this possible within the same process - perhaps by changing the Window hierarchy of ownership/parentage.
2010-03-23 08:48:56
So you want Dialog A to be non-responsive when the user has Dialog C open, but you still want them to be able to interact with Dialog B? As I said a modal dialog will block all interaction with the application until that modal dialog is closed. The only way you could do this is to open Dialog C with Show(), then change Dialog A's Enabled property (so it disables all controls) when Dialog C is opened, then changes it back to Enabled when Dialog C is closed.
Andy Shellam
2010-03-23 08:54:14
ok, sounds like a good idea.
2010-03-23 08:56:11
Hmmm, slight problem - when Dialog C is modeless, it can be lost when one interacts with B - with the best option being to show C in taskbar which does not seem right for what ought to be a modal dialog.
2010-03-23 09:35:08
http://stackoverflow.com/questions/1388408/is-there-a-way-to-auto-hide-a-always-on-top-modeless-dialog-when-the-parent-opensthis suggests using hooks, but the solution is not clear
2010-03-23 09:43:47
"which does not seem right for what ought to be a modal dialog" - I disagree. I've seen apps where the modal dialog is smaller than the inactive dialog behind it, so if you click on that dialog you "lose" the modal dialog. If you have no taskbar button, the only way you get back to the modal window is ALT+TAB - that's not right to me. The taskbar is the first place I look to find an app's window.
Andy Shellam
2010-03-23 09:46:15