A
Andrew
I am having problems with modal windows going behind the main form and
confusing users. I have found the simplest way to simulate this in VS by
putting a break point on a line to take focus away from the app.
When you run the code below and put a break point on the dummy statement and
when it goes into debug mode press F5 to continue the app you will see that
the message box is somehow separate from the main app. You can click on the
Windows task bar to select the app and the message box then goes behind.
This is all caused by the DoEvents statement, if you take this out it works
fine.
My question is what is the DoEvents statement doing to mess things up and
how can I fix this (without removing the DoEvents statement)?
Put this code inside a button click event on the main form:
// Put a break point on the code below
int Dummy = 1;
Application.DoEvents();
MessageBox.Show("This may now go behind main window");
Thanks for any help
Andrew
confusing users. I have found the simplest way to simulate this in VS by
putting a break point on a line to take focus away from the app.
When you run the code below and put a break point on the dummy statement and
when it goes into debug mode press F5 to continue the app you will see that
the message box is somehow separate from the main app. You can click on the
Windows task bar to select the app and the message box then goes behind.
This is all caused by the DoEvents statement, if you take this out it works
fine.
My question is what is the DoEvents statement doing to mess things up and
how can I fix this (without removing the DoEvents statement)?
Put this code inside a button click event on the main form:
// Put a break point on the code below
int Dummy = 1;
Application.DoEvents();
MessageBox.Show("This may now go behind main window");
Thanks for any help
Andrew