MessageBox bug?

W

Wayne

I posted this in microsoft.public.dotnet.languages.csharp with name of "Bug
in Framework?"

Drop a timer on the form, set it's interval to 1000 and put this in for the
timer event:

timer1.Enabled = false;
MessageBox.Show("TEST");

Run the application and make sure to take focus away from the form/App. I
just select my News reader. Once you do this and the message box displays
the form is selectable.

I know calling MessageBox.Show(this, "TEST") will make it work just fine,
but shouldn't the method work the same in every case?

--
Thanks
Wayne Sepega
Jacksonville, Fl


"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
 
G

Guest

Hi Wayne,

When MessageBox.Show is called without passing an IWin32Window, it will call
UnsafeNativeMethods.GetActiveWindow which returns a handle to the active
window for the message loop that belongs to that thread.

If your application isn't active, then GetActiveWindow will return null -
this is why your form is selectable even though a messagebox is being
displayed. It's definitely not a bug in the framework, and the fix you've
suggested is exactly what you should be doing.

Hope this helps.

Regards,
Matt Garven
 
W

Wayne

I understand why it works the way it does, I just don't understand why it is
correct. I mean shouldn't the message box really look for the applications
currently active window? or modal each of the currently displayed windows?

I just question the way it is implemented due to the fact that it doesn't
operate the same in all scenarios and something like this should.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DataGrid multi select 3
TollBox Pushpin effect 2
Beta 2 News Groups 1
Hide Cells from printing 2
windows form datagrid questions 2
Profiling tool for C# and .net 2.0 2
Bug in the framework? 9
XmlSerializer 3

Top