MessageBox Appearing Behind Window
-
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it?
The difficult we do right away... ...the impossible takes slightly longer.
-
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it?
The difficult we do right away... ...the impossible takes slightly longer.
The problem is that ShowDialog is a blocking call: it doesn't return control to the UI thread until the dialog has been dismissed. And MessageBox.Show is also a blocking call: it's the equivelant of calling ShowDialog on a "normal" form. You don't really have many options here other than to create your own message box and call Show on that if you must be able to continue working with it visible.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it?
The difficult we do right away... ...the impossible takes slightly longer.
You need a different "pattern". If the "error" is critical, exit the dialog, then give the message; then "retry" based on ok / cancel. Or the "dialog" might function better as a "wizard" (next; back; cancel).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
You need a different "pattern". If the "error" is critical, exit the dialog, then give the message; then "retry" based on ok / cancel. Or the "dialog" might function better as a "wizard" (next; back; cancel).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
These are great ideas, thanks!
The difficult we do right away... ...the impossible takes slightly longer.
-
These are great ideas, thanks!
The difficult we do right away... ...the impossible takes slightly longer.
You're welcome!
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it?
The difficult we do right away... ...the impossible takes slightly longer.
Assuming you're using WPF... You could try my Customizable WPF MessageBox[^].
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I'm having a problem with a MessageBox.Show() call. It's being called from a window that was shown with Form.ShowDialog(). The problem is that the message box sometimes appears behind the dialog box, and makes the dialog box unresponsive until the message box window is found and OK is clicked on it. This would be terribly confusing for users. Is there any way to guarantee that a message box is displayed above the form that is calling it?
The difficult we do right away... ...the impossible takes slightly longer.
When you call MessageBox.Show(), you can pass the owner form as a parameter. This ensures that the message box will always be displayed above the owner form.
-
When you call MessageBox.Show(), you can pass the owner form as a parameter. This ensures that the message box will always be displayed above the owner form.
Thanks! I'll try this.
The difficult we do right away... ...the impossible takes slightly longer.