By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

MessageBox.Show is showing BEHIND the application

P: n/a
For some reason, I have an errormessage popup that "blinks", but pops up
BEHIND the applications, which is confusing to users.

Is there any way to force it to the top?
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Bill,
I can't reproduce your problem. However try to pass reference to the form as
messagebox' owner.

If it doesn't help I would suggest you to post some code that demonstrates
the problem.
--

Stoitcho Goutsev (100) [C# MVP]
"Bill" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
For some reason, I have an errormessage popup that "blinks", but pops up
BEHIND the applications, which is confusing to users.

Is there any way to force it to the top?

Nov 16 '05 #2

P: n/a
Bill,
Are you using one of the overloads to MessageBox.Show that expects the
IWin32Window owner parameter?

Control implements IWin32Window, so you can just pass you current form
(this).

Hope this helps
Jay
"Bill" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
For some reason, I have an errormessage popup that "blinks", but pops up
BEHIND the applications, which is confusing to users.

Is there any way to force it to the top?

Nov 16 '05 #3

P: n/a
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:u9**************@TK2MSFTNGP12.phx.gbl...
Hi Bill,
I can't reproduce your problem. However try to pass reference to the form as messagebox' owner.

If it doesn't help I would suggest you to post some code that demonstrates
the problem.
--

Stoitcho Goutsev (100) [C# MVP]


I am displaying the error message as follows:

private void SummaryView_Load(object sender, System.EventArgs e)
{
try
{
twsDS1 = SummaryBO.Instance.twsDS;
}
catch (Exception err)
{
MessageBox.Show("Data Error:\n" + err.Message);
return;
}
}
Nov 16 '05 #4

P: n/a
Bill,
What Stoitcho & I are suggesting is:

MessageBox.Show(this, "Data Error:\n" + err.Message);

As long as SummaryView_Load is in a form.

Also, rather scattering try/catch/MessageBox all over my app I would use a
global exception handler with a single try/catch/MessageBox that is able to
log the exception & show it to the user.

Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

It can be beneficial to combine the above global handlers in your app, as
well as wrap your Sub Main in a try catch itself.

There is an article in the June 2004 MSDN Magazine that shows how to
implement the global exception handling in .NET that explains why & when you
use multiple of the above handlers...

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

For example: In my Windows Forms apps I would have a handler attached to the
Application.ThreadException event, plus a Try/Catch in my Main. The
Try/Catch in Main only catches exceptions if the constructor of the MainForm
raises an exception, the Application.ThreadException handler will catch all
uncaught exceptions from any form/control event handlers.

Hope this helps
Jay
"Bill" <nf*@nospam.com> wrote in message
news:On*************@TK2MSFTNGP11.phx.gbl...
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:u9**************@TK2MSFTNGP12.phx.gbl...
Hi Bill,
I can't reproduce your problem. However try to pass reference to the form
as
messagebox' owner.

If it doesn't help I would suggest you to post some code that

demonstrates the problem.
--

Stoitcho Goutsev (100) [C# MVP]


I am displaying the error message as follows:

private void SummaryView_Load(object sender, System.EventArgs e)
{
try
{
twsDS1 = SummaryBO.Instance.twsDS;
}
catch (Exception err)
{
MessageBox.Show("Data Error:\n" + err.Message);
return;
}
}

Nov 16 '05 #5

P: n/a
Hello, Bill!
I don't have MessageBox control in the list of the controls.
When I manually create:
System.Windows.Forms.MessageBox a=new MessageBox();
The code compiles, but I see a warning:
System.Windows.Forms.MessageBox is inaccessible due to its protection level

What the heck is it and how do I change the protection level?

With best regards, Nurchi BECHED.
Nov 16 '05 #6

P: n/a
Nurchi,
MessageBox is not a Control per se, it is a "static" class the will display
a specific dialog box, the Win32 message box.

A "static" class is a class that only has static methods, you do no
instantiate an instance of the class to use it, you simply call the methods.

Something like:

MessageBox.Show(this, "Data Error:\n" + err.Message);

System.Windows.Forms.MessageBox & System.Math are both example of a "static"
class.

Hope this helps
Jay

"Nurchi BECHED" <nu****@telus.net> wrote in message
news:sNCOc.1504$T_6.1359@edtnps89...
Hello, Bill!
I don't have MessageBox control in the list of the controls.
When I manually create:
System.Windows.Forms.MessageBox a=new MessageBox();
The code compiles, but I see a warning:
System.Windows.Forms.MessageBox is inaccessible due to its protection level
What the heck is it and how do I change the protection level?

With best regards, Nurchi BECHED.

Nov 16 '05 #7

P: n/a
Hello, Jay!

Yes, but in the past there was a 'control' that you could put on your
form...
Just like OpenFileDialog or SaveFileDialog...
I was able to put that object on the form and then use it in my code...

You wrote on Sat, 31 Jul 2004 13:17:36 -0500:

JBH> A "static" class is a class that only has static methods, you do no
JBH> instantiate an instance of the class to use it, you simply call the
JBH> methods.

JBH> Something like:

JBH> MessageBox.Show(this, "Data Error:\n" + err.Message);

JBH> System.Windows.Forms.MessageBox & System.Math are both example of a
JBH> "static" class.

JBH> Hope this helps
JBH> Jay

JBH> "Nurchi BECHED" <nu****@telus.net> wrote in message
JBH> news:sNCOc.1504$T_6.1359@edtnps89...
??>> Hello, Bill!
??>> I don't have MessageBox control in the list of the controls.
??>> When I manually create:
??>> System.Windows.Forms.MessageBox a=new MessageBox();
??>> The code compiles, but I see a warning:
??>> System.Windows.Forms.MessageBox is inaccessible due to its protection
JBH> level
??>>
??>> What the heck is it and how do I change the protection level?
??>>
??>> With best regards, Nurchi BECHED.
??>>

With best regards, Nurchi BECHED.
Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.