Mouse Events in IC Imaging Control .NET and C#
Posted by Stefan Geißler on February 14, 2007
Sometimes it is necessary to handle a mouse click event when one occurs onto top of a live display. For this purpose, IC Imaging Control .NET provides mouse event handlers. In these event handlers, functions of the main form should not be called, as the IC Imaging Control mouse event handler runs in thread that is different from the main application. Thus, Delegates should be used.
The following sample code enhances the C# Full Screen sample application. Instead of closing the application when the mouse is clicked, the application's window is resized to 640 x 480 pixel.
In the first step, we have to create our Delegate:
private delegate void ResizeDelegate();
In the second step, we write our "ResizeBack" method - this will resize the window to 640 x 480 pixels:
private void ResizeBack() { WindowState = FormWindowState.Normal; FormBorderStyle = FormBorderStyle.Sizable; Width = 640; Height = 480; }
In the third and final step, we have to call the Delegate "ResizeDelegate" and pass the method from which it should be called to the IC Imaging Control mouse event handler:
private void icImagingControl1_MouseUp(object sender,
TIS.Imaging.ICImagingControl.MouseEventArgs e) { BeginInvoke( new ResizeDelegate( ResizeBack ) ); }
Tagged with Mouse EventC#.NETDelegateSample Application.


