PDA

View Full Version : MouseMove don't work



Droise
March 19, 2013, 21:20:47
Hello,
probably it's a simple question, but i can't find my error. I'm working in visual basic on visual studio 2010.
I try to use this code:


Private Sub IcImagingControl1_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal XPos As Integer, ByVal YPos As Integer)
X_mouse = XPos
Y_mouse = YPos
End Sub

to get mouse pointer position when mouse is moved on IcImagingControl1 display area, but code don't work. I try also to put a breackpoint in the Sub, but it never is executed. Is there some setting i must do in IcImagingControl1 to enable this function? I could use Sub for mouse click... is it IcImagingControl1_MouseDown?

Thank you!
Best regards.

Stefan Geissler
March 20, 2013, 08:55:22
Hi,

I created a small C# .NET project and added the mouse move event handler using the properties window of the designer. Then I had this code:


private void icImagingControl1_MouseMove(object sender, MouseEventArgs e)
{
Console.WriteLine("x:{0} y:{1}", e.X, e.Y);
}


which is working fine. The very same in VB .NET is


Private Sub IcImagingControl1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles IcImagingControl1.MouseMove
Console.WriteLine("x:{0} y:{1}", e.X, e.Y)
End Sub


I just wonder, whether you do not use .NET (this is .NET forum) but the ancient VB6 and the ActiveX. It may is possible, the mouse move does not work in the ActiveX, but the mouse click event work.

Droise
March 20, 2013, 13:35:31
Yes, i'm using VB 2010. Which is the right sintax for mouse click event sub?
Where can i find a list of all IcImagingControl function for future use?

Thank you!
Best regards.

Stefan Geissler
March 20, 2013, 16:17:13
If you use VB 2010, as I did in my sample, I wonder, why the automatically created mouse move event handler looks completely different from mine, as shown in my post.

Did you create the mouse move event handler from the design window -> properties ?

Droise
March 20, 2013, 18:22:28
Ok, with code like example for .NET it work correctly!
Which is the sub for mouse click instead?

Thank you!
Best regards.

Stefan Geissler
March 21, 2013, 10:19:14
You can add the event handlers automatically from your form using the Visual Studio Forms Designer functions. In there, all events are listed, also the mouse click and so on.