View Full Version : MouseMove not working

August 30, 2007, 21:16:11

I'm testing a very simple application.

1)drop an ICImagingControl in your form
2)set the following code for its MouseMove event:

private void ic_MouseMove(object sender, TIS.Imaging.ICImagingControl.MouseEventArgs e)
frmMain.ActiveForm.Text = "got it";

Originally I was trying to get the e.x and e.y values unsuccessfully when I decided to simplify even more.

I'm using VS2005 under windows vista. If I set a breakpoint in that line, it stops there, freezes for about 3 seconds and then returns, but nothing changes (I tried with a label instead of form caption as well).

Any hints?

Sascha Schmidt
August 31, 2007, 14:46:27

you have to do that with a delegate, because the mouse event runs in another thread and you may not access controls from that thread:

private void icImagingControl1_MouseMove(object sender, ICImagingControl.MouseEventArgs e)
BeginInvoke(new ICImagingControl.MouseEventHandler(icMouseMove_Eve nt), new object[] { sender, e });

private void icMouseMove_Event(object sender, ICImagingControl.MouseEventArgs e)
label1.Text = "X: " + e.x.ToString() + " Y: " + e.y.ToString();

January 14, 2008, 22:39:06

What's up with this delegation function at mouse events ?

The "Movable Crosshair on an Overlay" example doesn't need it
but I had to use it in my project without understanding why
- this makes me a little bit nervous ...


Stefan Geissler
January 15, 2008, 10:02:02

The delegates should be used in any case with IC 3.0.x. But they are necessary in any case, if output is done on controls of the form. They are necessary, because the ImageAvailable event is fired and executed in another thread than the message thread of the form.