以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  摄像头的老问题--未将对象引用设置到对象的实例  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=144249)

--  作者:gudao123456
--  发布时间:2019/12/15 9:53:00
--  摄像头的老问题--未将对象引用设置到对象的实例
在表事件afterlaod引用摄像头后,总出现“未将对象引用设置到对象的实例。”,如何解决?谢谢!
--  作者:有点蓝
--  发布时间:2019/12/15 20:20:00
--  
勾选显示详细信息,看是哪个事件有问题,把代码贴上来。另外这个电脑有开摄像头吗
--  作者:gudao123456
--  发布时间:2019/12/17 17:18:00
--  
在表事件:afterload ,在两个表中设置有,所以出错了两次,没有摄像头出现,但把摄像头插上去,也同样提示。但插上的摄像头能正常使用
代码:
try
    Dim cmr As New DCap.Filters()
catch ex As exception
    msgbox("没有设备")
    \'Return
    e.Form.close
    \'Return
End try
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
Forms("查看证明材料").Controls("PictureViewer1").open()
[此贴子已经被作者于2019/12/17 17:19:49编辑过]

--  作者:有点蓝
--  发布时间:2019/12/17 17:42:00
--  
调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm

看是那一句代码出错

--  作者:gudao123456
--  发布时间:2019/12/18 11:35:00
--  
已解决。谢谢!