Issue with messageBox

M

Mukesh

Hi
I just fould a issue with MessgeBox. When i show the messagebox in my
app. Now if the user click any where else on the form out of messagebox. The
click event is kind put in a que. Now if there is a button or other control
where that person clicked, the button / control click event is fired after
my earlier procedure has finished.

Here is how you can duplicate the thing.

- Create a windowsform, put a button control on it,
- Write a procedure onClick event of button

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click
MessageBox.show("Test", "Test", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
MessageBoxOptions.DefaultDesktopOnly)
End Sub

- Now Build and run the app
- Click the button
- {move the Messagebox out of the way, so you can see the button}
- click on the button again
- now click any button on the Messagebox
- {Now here is the problem} you will see the message box again. {message box
for second click}

can some tell how disable this feature in my app. or work around.

i have tried disabling the control and also form before displaying the
messagebox but still the same problem.

Can anybody help

Thanks in advance
mk
 
C

ClayB [Syncfusion]

I tried your sample and I did see strange behavior, but not exactly what you
described. What I see as I drag the messagebox over the form, the form does
not repaint properly, and wierd things start to happen. I used .NET 1.1 SP1.

When I removed the last argument in the Message.Show call,
MessageBoxOptions.DefaultDesktopOnly, the problem I saw went away.

=========================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
N

Norman Yuan

The "Problem" is the argument MessageBoxOptions.DefaultDesktopOnly in
MessageBox.Show() method. If you are calling MessageBox from a Win Form, you
do not use this option.

This Option is basically the same as another option
"MessageBoxOptions.ServiceNotification", used in a process where no form is
presented (no form at all, or maybe, form is hidden).
 

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

Top