Please confirm Bug with OpenFileDialog

G

Guest

When opening a filedialog and the user double-clicks to select a file the
mouseup event is raised on the control behind the dialog. Is there a way to
handle this "bug"?

Code to reproduce (ensure the filedialog is over the form when
double-clicking, maximize?):

Public Class Form1

Private Sub Form1_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
MsgBox("Bang!")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim filedialog As New OpenFileDialog


filedialog.ShowDialog()
End Sub
End Class

Thanks
 
B

Bryan Phillips

You can cheat if you temporarily remove the button's event handler and
add it back after the OpenFileDialog closes:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Removehandler Button1.Click, AddressOf Button1_Click
Dim filedialog As New OpenFileDialog

filedialog.ShowDialog()
AddHandler Button1.Click, AddressOf Button1_Click
End Sub
 
G

Guest

The simple example I gave is only to replicate the effect. In fact, the
WM_MOUSEUP is sent to ANY control in the application window that happens to
be behind the OpenFileDialog. As such, because there is no way of detecting
the location of the Dialog you really don't have a way of detecting which
control to remove the MouseUp handler. It just sounds to me too much of a
hack if I am to do this.

At first stage it would be good if someone can confirm the bug. Handling it
is another issue all together which could also include the disablement of the
form ...
 
B

Bryan Phillips

I was able to reproduce it using your example which is why I replied
with a workaround. I apologize for not being clear.
 
G

Guest

No need to apologise Brian. Indeed the workaround would work if you knew
which control is under the dialog when the double-click occurs. However, this
is not the case hence my request to confirm the bug. I suspect that I will
need to way for a patch from MS.

To put things in prespective, I have an MDI form with multiple child windows
which manipulate CAD data as well as text, buttons etc. I have designed the
app to handle right clicks in different ways depending on the control, so
writting a work-around involves re-designing the app in essence and it would
take heaps of time. It is not a crucial issue but because of the large size
of the data being processed, sending a right click to a "viewer" window
causes the user to get misintepreted results when opening the drawings for
the first time as they automatically zoom-out because of the mouse_up event.
Again, there are lots of ways to handle the issue, but in this scenario, I am
looking to get a confirmation from MS of the bug and possibly a workaround
which works on the dialog itself rather than the application.

Thanks again.
 

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