Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox is modal to the desktop

I'm working on my first WinForms application...I typically write web apps...

A strange thing is happening with my application today. If I run the application on my computer, or my co-worker runs it on his computer, my MessageBoxes are modal only to my application. This is the desired behavior. My users will need to be able to make manual edits in a separate application if a message box appears, and clicking "OK" in the message box will "unpause" my application and allow them to continue.

We just went to install a beta of the application on two end users' computers this afternoon and for some reason when we run the application on either of their computers the message boxes are modal to the desktop - nothing else can receive focus until "OK" is clicked. This behavior causes a HUGE issue for my application.

I don't know what could be different on the users' machines to cause this behavior. My computer - Win7 64-bit, my co-worker's computer - Win7 32-bit, two users' computers are Win7 32-bit. All have .Net Framework 4.5 or 4.5.1 installed.

Any advice?


UPDATES:

2014.11.17 - code snippet

DialogResult result = MessageBox.Show("The Style field did not pass validation.  
                      Please manually fix the data then click OK to continue.", 
                      "WARNING", MessageBoxButtons.OK, 
                      MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
like image 352
CDR12 Avatar asked Nov 10 '22 23:11

CDR12


1 Answers

If Hans Passant had posted an answer rather than a comment I would've marked his response as the answer.

This is how I resolved the issue:

DialogResult result = MessageBox.Show(t2tWindow, "The Style field did not pass 
                      validation.  Please manually fix the data then click OK 
                      to continue.", "WARNING", MessageBoxButtons.OK, 
                      MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

This code is in a separate "utility" class, not in the form's code-behind, so I had to pass an IWin32Window parameter into the method so I could pass it to the Show() method.

like image 89
CDR12 Avatar answered Nov 14 '22 23:11

CDR12