MouseUp-Event gets 'lost'

M

Michael Maes

Hi,

I have a child-form in an MDI-Application which seems to loose the MouseUp-Event.
I grid (for navigation-purpose) appears on many of the child-forms and in (I think) only one this issue occurs.

What happens:

Private Sub grdNavigation_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdNavigation.MouseDown
Debug.WriteLine("Down: " & e.Button.ToString)
End Sub

Private Sub grdNavigation_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdNavigation.MouseUp
Debug.WriteLine("Up: " & e.Button.ToString)
End Sub

This simple (to clarify the issue) snippet should output:
Tab - Down: Left
Tab - Up: Left
Tab - Down: Right
Tab - Up: Right
It does so for the left button, but with the right button the event happens only every 2 to 5 times.

I've hooked-up Spy++ and I can see the WM_RBUTTONUP-Message every time I release the R-Button.

I've also tried to comment-out all the code in the child-form (exept the designer-code & the mouse-up/down of course) but that makes no difference.

Any-one any clue where to 'look'.

Thanks,

Michael

PS: Just a note: the form contains a TabControl (Maybe 'another' bug?)

I'm using:
a.. vb.Net 2003 Enterprise Architect Edition
b.. Windows XP SP1a
 
P

Peter Huang

Hi,

What do you mean by the grid?

I can not reproduce the problem.
Here is my reproduce steps.
1. Create a new windowform project
2. Add two forms( one set IsMDIContainer to true)
3. Add a tabcontrol onto the child form and add the datagrid onto the
tabpage( I also tried add the datagird onto the form directly)
4. Add the MouseDown and MouseUp event handler

Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
Debug.WriteLine("Down: " & e.Button.ToString)
End Sub

Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseUp
Debug.WriteLine("Up: " & e.Button.ToString)
End Sub

You may try my reproduce steps to see if the problem persists.

Also can you simplify your code and post it here for me to further
troubleshooting.

I look forward to hearing from you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Maes

I think I have to go back to school (form my english anyway)
Hi,

I have a child-form in an MDI-Application which seems to loose the MouseUp-Event.
I grid (for navigation-purpose) appears on many of the child-forms and in (I think) only one this issue occurs.
A (data)grid (for navigation-purpose) appears on many of the child-forms (of the MDI-Application) and (I think) only this one (form) has the issue.

What happens:

Private Sub grdNavigation_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdNavigation.MouseDown
Debug.WriteLine("Down: " & e.Button.ToString)
End Sub

Private Sub grdNavigation_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdNavigation.MouseUp
Debug.WriteLine("Up: " & e.Button.ToString)
End Sub

This simple (to clarify the issue) snippet should output:
Tab - Down: Left
Tab - Up: Left
Tab - Down: Right
Tab - Up: Right
It does so for the left button, but with the right button the event happens only every 2 to 5 times.

I've hooked-up Spy++ and I can see the WM_RBUTTONUP-Message every time I release the R-Button.

I've also tried to comment-out all the code in the child-form (exept the designer-code & the mouse-up/down of course) but that makes no difference.

Any-one any clue where to 'look'.

Thanks,

Michael

PS: Just a note: the form contains a TabControl (Maybe 'another' bug?)

I'm using:
a.. vb.Net 2003 Enterprise Architect Edition
b.. Windows XP SP1a
 
P

Peter Huang

Hi Michael,

I am sorry if I did not ask for information properly. What I mean is what
kind of grid do you use.
Since there is two grid in winform controls (Property Grid and datagrid).
Also I think you perhaps use another grid which is created by others.

Now I have know that the problem persists with a datagrid.
And your senario is as below.
You have a few child forms and the child form have datagrid on the each
child form. One of your form did not work proper with the Right mouse
button down.

Since the problem persists in just one of your childform.
To isolate the problem I think you may try to recreate a childfrom and add
the datagrid onto the form and your codes one function by one functions see
if the problem persists.

If the problem still persists, you may try to inherits the DataGrid and
override its winproc function to see if the WM_RBUTTONDOWN and WM_RBUTTONUP
have been captured by datagrid.

Here is my code you may have a try.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mg As New MyGrid
Me.Controls.Add(mg)
End Sub
End Class

Public Class MyGrid
Inherits DataGrid
Public Enum MouseMessage As Integer
WM_LBUTTONDOWN = &H201
WM_LBUTTONUP = &H202
WM_RBUTTONDOWN = &H204
WM_RBUTTONUP = &H205
End Enum
Dim mm As MouseMessage
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
mm = m.Msg
If Len(mm.ToString()) > 5 Then
Console.WriteLine(mm.ToString)
End If
MyBase.WndProc(m)
End Sub
End Class


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Michael Maes

Hi Peter,

Seems like I've found the problem.

I've stripped-down the form control by control and located the problem in
the mnuEdit - contextmenu.
It was assigned to the form thus (probably) interfering with the WM.

I'dd realy like to thank you for helping me.

Kind regards,

Michael

PS: Still have to examine the "Configuring a VPN Tunnel through vb.Net"

| Hi Michael,
|
| I am sorry if I did not ask for information properly. What I mean is what
| kind of grid do you use.
| Since there is two grid in winform controls (Property Grid and datagrid).
| Also I think you perhaps use another grid which is created by others.
|
| Now I have know that the problem persists with a datagrid.
| And your senario is as below.
| You have a few child forms and the child form have datagrid on the each
| child form. One of your form did not work proper with the Right mouse
| button down.
|
| Since the problem persists in just one of your childform.
| To isolate the problem I think you may try to recreate a childfrom and add
| the datagrid onto the form and your codes one function by one functions
see
| if the problem persists.
|
| If the problem still persists, you may try to inherits the DataGrid and
| override its winproc function to see if the WM_RBUTTONDOWN and
WM_RBUTTONUP
| have been captured by datagrid.
|
| Here is my code you may have a try.
|
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| System.EventArgs) Handles Button1.Click
| Dim mg As New MyGrid
| Me.Controls.Add(mg)
| End Sub
| End Class
|
| Public Class MyGrid
| Inherits DataGrid
| Public Enum MouseMessage As Integer
| WM_LBUTTONDOWN = &H201
| WM_LBUTTONUP = &H202
| WM_RBUTTONDOWN = &H204
| WM_RBUTTONUP = &H205
| End Enum
| Dim mm As MouseMessage
| Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
| mm = m.Msg
| If Len(mm.ToString()) > 5 Then
| Console.WriteLine(mm.ToString)
| End If
| MyBase.WndProc(m)
| End Sub
| End Class
|
|
| Best regards,
|
| Peter Huang
| Microsoft Online Partner Support
|
| Get Secure! - www.microsoft.com/security
| This posting is provided "AS IS" with no warranties, and confers no
rights.
|
 

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