Changing the Mouse Cursor Programming example that illustrates how to change IC Imaging Control's mouse cursor.
This sample shows how to change the mouse cursor in IC Imaging Control. The window of the resulting application looks as follows: In order to change the mouse cursor in IC Imaging Control, an extra DLL needs to be used. The DLL icsetcursor.dll exports the function FindICWindow, receives the application's window handle and the file name of the cursor. First of all the function FindICWindow must be declared in the application: C# [System.Runtime.InteropServices.DllImport ("icsetcursor.dll")] private extern static long FindICWindow(IntPtr ParentWindow, string szCursorName); VB.NET Declare Ansi Function FindICWindow Lib "icsetcursor.dll" (ByVal hWnd As IntPtr, _ ByVal CursorFile As String) As Long The declaration must use Ansi in Visual Basic, because the DLL does not support unicode file names. After the application has been compiled for the first time, the files icsetcursor.dll and cross.cur must be copied into the directories bin\debug and bin\release for C# and bin for Visual Basic projects. The "DLL not found" exception is thrown, if the files could not be copied. In the Form_load functions, the cursor is set for the first time: C# try { // Set the cursor. FindICWindow(this.Handle,"cross.cur"); } catch { // In order to avoid the application stops in case the "icsetcursor.dll" is // missing, the application catches the "DLL not found" exception. MessageBox.Show("The DLL \"icsetcursor.dll\" was not found.\nPlease make sure it is saved in your working directory!","Set Cursor"); } VB.NET Try ' Set the cursor. FindICWindow(Me.Handle, "cross.cur") Catch ' In order to avoid the application stops in case the "icsetcursor.dll" is ' missing, the application catches the "DLL not found" exception. MessageBox.Show("The DLL 'icsetcursor.dll' was not found.Please make sure it is saved in your working directory!", "Set Cursor") End Try For convenience, the call to FindICWindow is encapsulated in a try - catch block in order to catch the "DLL not found" exception in case the icsetcursor.dll is not in the application's working directory. After the live video has been started, the new cursor must be set again, because a new internal window was opened. Thus, FindICWindow must be called again to set the mouse cursor. C# private void StartLiveVideo() { icImagingControl1.LiveStart(); menuItemLiveStart.Enabled = false; menuItemLiveStop.Enabled = true; tbStartLive.Enabled = false; tbStopLive.Enabled = true; // Set the cursor to the live video's display window. FindICWindow(this.Handle,"cross.cur"); } VB.NET 'Start the live video. Private Sub StartLiveVideo() With IcImagingControl1 If (.DeviceValid) Then .LiveStart() FindICWindow(Me.Handle, "cross.cur") EnableControlls() End If End With End Sub |