以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 报错如何解决 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=124574)
|
-- 作者:nxqtxwz
-- 发布时间:2018/9/9 18:39:00
-- 报错如何解决
请问我的系统中有用摄像头拍照的功能,但有的电脑上没有摄像头就会出现下面的错误提示,怎么能让它不提示呢?
.NET Framework 版本:2.0.50727.8793 Foxtable 版本:2018.9.9.1 错误所在事件:项目,AfterOpenProject 详细错误信息: “UserCode”的类型初始值设定项引发异常。 No devices of the category
|
-- 作者:有点甜
-- 发布时间:2018/9/9 19:59:00
--
提示这个错误【No devices of the category】,说明电脑上没有摄像头。
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=84349&skin=0
如果是win10的电脑,有可能不能调用摄像头,还一种方式试试
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=93741
|
-- 作者:nxqtxwz
-- 发布时间:2018/9/10 22:16:00
--
我按老师的指导中第一个例子改了全局变量和内部函数,启动时正常了。但在照相是如果没有摄像头会提示:没有摄像头,然后报错:
.NET Framework 版本:2.0.50727.8793 Foxtable 版本:2018.9.9.1 错误所在事件:窗口,拍照,AfterLoad 详细错误信息: InvalidArgument=“0”的值对于“index”无效。 参数名: index
窗口,拍照,AfterLoad的代码是:
Dim camList As WinForm.ComboBox = e.Form.Controls("CamList") \'设置控件大小 Functions.Execute("SetCamBoxSize",e.Form,True) \'设置移动条 e.Form.Controls("BarX").Value = e.Form.Controls("LineBox").Left - e.Form.Controls("CamViewBox").Left e.Form.Controls("BarY").Value = e.Form.Controls("CamViewBox").Height - (e.Form.Controls("LineBox").Top - e.Form.Controls("CamViewBox").Top) e.Form.Controls("BarW").Value = e.Form.Controls("LineBox").Width e.Form.Controls("BarH").Value = e.Form.Controls("CamViewBox").Height - e.Form.Controls("LineBox").Height \'显示拍照框尺寸 e.Form.Controls("BoxW").Value = e.Form.Controls("LineBox").Width e.Form.Controls("BoxH").Value = e.Form.Controls("LineBox").Height _lVars(0) = e.Form.Controls("AutoTake").Checked \'设置保存路径 If _sVars(0) <> "" e.Form.Controls("FileName").Value = _sVars(0) End If \'获取摄像头列表 Functions.Execute("GetCams") \'显示摄像头列表 Dim i As Integer camList.Items.Clear For i=0 To _CamList.Count - 1 camList.Items.Add(_CamList(i)) Next \'默认选中第一个摄像头 If _CamList.Count > 1 And _CamIndex < 1 _CamIndex = 1 End If camList.SelectedIndex = _CamIndex \'激活预览 If _CamList.Count > 0 Functions.Execute("SetCamView",_CamIndex,e.Form.Controls("CamView")) Else MessageBox.Show("未检测摄像头,请先连接摄像头!","警告") e.Form.Close() End If \'启动定时器 _iVars(0) = 0 e.Form.TimerEnabled = True
|
-- 作者:有点蓝
-- 发布时间:2018/9/10 22:41:00
--
http://www.foxtable.com/webhelp/scr/1485.htm
看看是哪一句代码出错
|
-- 作者:有点甜
-- 发布时间:2018/9/11 9:21:00
--
AfterLoad 事件那里,不是可以判断是否有摄像头?如果没有,就把窗口关闭。
或者是,直接就不要把拍照窗口打开了。直接提示没有摄像头。
|
-- 作者:nxqtxwz
-- 发布时间:2018/9/16 17:01:00
--
报错的问题解决了,但没有摄像头的提示出现后,如果点确定或直接关闭提示窗口,项目就处于静止状态,点哪都不动了。必须退出或点一下项目图标才能正常,是不是没有完全退出拍照窗口呢。
If _CamList.Count > 0 Functions.Execute("SetCamView",_CamIndex,e.Form.Controls("CamView")) Else MessageBox.Show("未检测摄像头,请先连接摄像头!","警告") e.Form.Close() End If \'启动定时器 _iVars(0) = 0 e.Form.TimerEnabled = True
|
-- 作者:有点甜
-- 发布时间:2018/9/16 17:53:00
--
我这样测试没问题
If _CamList.Count = 0 Then e.Form.close Return End If
Dim camList As WinForm.ComboBox = e.Form.Controls("CamList") \'设置控件大小 Functions.Execute("SetCamBoxSize",e.Form,True) \'设置移动条 e.Form.Controls("BarX").Value = e.Form.Controls("LineBox").Left - e.Form.Controls("CamViewBox").Left e.Form.Controls("BarY").Value = e.Form.Controls("CamViewBox").Height - (e.Form.Controls("LineBox").Top - e.Form.Controls("CamViewBox").Top) e.Form.Controls("BarW").Value = e.Form.Controls("LineBox").Width e.Form.Controls("BarH").Value = e.Form.Controls("CamViewBox").Height - e.Form.Controls("LineBox").Height \'显示拍照框尺寸 e.Form.Controls("BoxW").Value = e.Form.Controls("LineBox").Width e.Form.Controls("BoxH").Value = e.Form.Controls("LineBox").Height _lVars(0) = e.Form.Controls("AutoTake").Checked \'设置保存路径 If _sVars(0) <> "" e.Form.Controls("FileName").Value = _sVars(0) End If \'获取摄像头列表 Functions.Execute("GetCams") \'显示摄像头列表 Dim i As Integer camList.Items.Clear For i=0 To _CamList.Count - 1 camList.Items.Add(_CamList(i)) Next \'默认选中第一个摄像头 If _CamList.Count > 1 And _CamIndex < 1 _CamIndex = 1 End If camList.SelectedIndex = _CamIndex \'激活预览 If _CamList.Count > 0 Functions.Execute("SetCamView",_CamIndex,e.Form.Controls("CamView")) Else MessageBox.Show("未检测摄像头,请先连接摄像头!","警告") e.Form.Close() End If \'启动定时器 _iVars(0) = 0 e.Form.TimerEnabled = True
|