
| 语言: | .NET C#/Visual Basic |
| 版本: | 3.0.3 |
| 发布于: | 2007年7月5日 |
| 作者: | IC Imaging Control 技术支持部 |
| 系统要求: | IC Imaging Control >2.1 由WDM数据流类驱动程序驱动的相机、视频转换器或图像采集卡 |
| |
这个例子演示的是如何改变 IC Imaging Control 中鼠标在屏幕中显示的形状。 程序窗体如图所示:

为了改变鼠标形状,程序还需要一个外部 DLL——icsetcursor.dll,它用于导出函数FindICWindow,接收程序窗口处理和鼠标文件名。
程序首先声明函数 FindICWindow:
[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
在Visual Basic中必须使用Ansi声明,因为 DLL 不支持 unicode 文件名。
在这个程序经过第一次编译之后, 如使用C#,文件 icsetcursor.dll 及 cross.cur 必须被拷贝至目录 bin\debug 与 bin\release, 如使用Visual Basic,必须被拷贝至 bin。 如文件没能被拷贝,则弹出 "DLL not found" exception 对话框。
在函数 Form_load 中,鼠标被第一次设置:
[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
为方便起见,对FindICWindow的调用被至于try - catch语句中,这样一来,如果icsetcursor.dll不在工作目录内,程序就会弹出 "DLL not found" exception 对话框。
开始现场视频后,因为一个新的内部窗口已被开启,程序需要设置新的鼠标, 所以再次调用 FindICWindow 设置鼠标。
[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
责任声明
IC Imaging Control 源代码库中的所有代码均只用于教学目的,The Imaging Source Europe GmbH 作为IC Imaging Control的开发制造商,不对任何由于使用本文或其中源代码所产生的后果承担责任。