- VERSION 5.00
- Begin VB.Form frmVideo
- Caption = "Video1"
- ClientHeight = 4065
- ClientLeft = 60
- ClientTop = 450
- ClientWidth = 6465
- LinkTopic = "Form1"
- MDIChild = -1 'True
- ScaleHeight = 4065
- ScaleWidth = 6465
- Visible = 0 'False
- Begin VB.Frame Frame1
- Caption = "显示比例"
- Height = 2415
- Left = 4800
- TabIndex = 1
- Top = 360
- Width = 1335
- Begin VB.OptionButton optRatio
- Caption = "自定义"
- Height = 375
- Index = 3
- Left = 120
- TabIndex = 7
- Top = 1560
- Width = 1095
- End
- Begin VB.TextBox txtOther
- Alignment = 1 'Right Justify
- Enabled = 0 'False
- Height = 270
- Left = 360
- TabIndex = 5
- Top = 1920
- Width = 615
- End
- Begin VB.OptionButton optRatio
- Caption = "200%"
- Height = 375
- Index = 2
- Left = 120
- TabIndex = 4
- Top = 1160
- Width = 1095
- End
- Begin VB.OptionButton optRatio
- Caption = "150%"
- Height = 375
- Index = 1
- Left = 120
- TabIndex = 3
- Top = 760
- Width = 1095
- End
- Begin VB.OptionButton optRatio
- Caption = "100%"
- Height = 375
- Index = 0
- Left = 120
- TabIndex = 2
- Top = 360
- Value = -1 'True
- Width = 1095
- End
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "%"
- Height = 180
- Left = 1080
- TabIndex = 6
- Top = 1965
- Width = 90
- End
- End
- Begin VB.Timer timer1
- Enabled = 0 'False
- Interval = 10
- Left = 5280
- Top = 3000
- End
- Begin VB.PictureBox picVideo
- Appearance = 0 'Flat
- AutoRedraw = -1 'True
- BackColor = &H00000000&
- BorderStyle = 0 'None
- ForeColor = &H80000008&
- Height = 3495
- Left = 240
- ScaleHeight = 3495
- ScaleWidth = 4095
- TabIndex = 0
- TabStop = 0 'False
- Top = 240
- Width = 4095
- End
- End
- Attribute VB_Name = "frmVideo"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim strTemp As String '模块变量,保存临时文件名
- Private Sub Form_Activate() '窗体激活事件
- picVideo.Width = frmCamera.ezVidCap1.Width '设置图片控件的宽度
- picVideo.Height = frmCamera.ezVidCap1.Height '设置图片控件的高度
- Frame1.Top = picVideo.Top '框架顶部与图片控件顶部对齐
- Frame1.Left = picVideo.Left + picVideo.Width + 200 '设置框架左边距
- If Me.WindowState <> vbMaximized Then '若窗体不是最大化状态
- Me.Width = Frame1.Left + Frame1.Width + 400 '设置窗体的宽度
- Me.Height = picVideo.Top + picVideo.Height + 800 '设置窗体的高度
- If Me.Height < Frame1.Top + Frame1.Height + 800 Then '若窗体小于框架
- Me.Height = Frame1.Top + Frame1.Height + 800 '设置窗体的高度
- End If
- End If
- End Sub
- Private Sub Form_Load()
- optRatio_Click (0) '选中100%
- strTemp = App.Path & "TEMPT" & Format(Now, "yyyymmddhhmmss") & ".tmp" '设置临时文件名
- timer1.Enabled = True '允许时钟控件
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- frmMain.tbToolBar.Buttons(1).Value = tbrUnpressed '弹起工具栏中的预览按钮
- frmMain.mnuPre1.Checked = False '取消预览菜单的选中状态
- End Sub
- Private Sub optRatio_Click(Index As Integer) '显示比例单选按钮
- timer1.Enabled = False '禁止时钟控件
- Select Case Index
- Case 0 '100%
- picVideo.Width = frmCamera.ezVidCap1.Width '设置图片控件的宽度
- picVideo.Height = frmCamera.ezVidCap1.Height '设置图片控件的高度
- Case 1 '150%
- picVideo.Width = frmCamera.ezVidCap1.Width * 1.5 '设置图片控件的宽度
- picVideo.Height = frmCamera.ezVidCap1.Height * 1.5 '设置图片控件的高度
- Case 2 '200%
- picVideo.Width = frmCamera.ezVidCap1.Width * 2 '设置图片控件的宽度
- picVideo.Height = frmCamera.ezVidCap1.Height * 2 '设置图片控件的高度
- Case 3 '自定义
- txtOther.Enabled = True '允许文本框输入内容
- txtOther.SetFocus '设置焦点
- Exit Sub '退出过程
- End Select
- Frame1.Left = picVideo.Left + picVideo.Width + 200 '设置框架坐标
- If Me.WindowState <> vbMaximized Then '若窗体不是最大化状态
- Me.Width = Frame1.Left + Frame1.Width + 400 '设置窗体宽
- Me.Height = picVideo.Top + picVideo.Height + 800 '设置窗体的高度
- If Me.Height < Frame1.Top + Frame1.Height + 800 Then '若窗体小于框架
- Me.Height = Frame1.Top + Frame1.Height + 800 '设置窗体的高度
- End If
- End If
- txtOther.Enabled = False '禁止文本框
- timer1.Enabled = True '允行时间控件
- End Sub
- Private Sub picVideo_DblClick() '双击图片控件
- timer1.Enabled = False '禁止时钟控件
- frmFull.Show vbModal '显示全屏窗体
- timer1.Enabled = True '允许时钟控件
- End Sub
- Private Sub timer1_Timer()
- With frmCamera.ezVidCap1
- If .CapSingleFrame Then '获取一个单帧
- picVideo.Cls '清空图片控件
- .SaveDIB strTemp '保存当前帧到临时文件
- picVideo.PaintPicture LoadPicture(strTemp), 0, 0, picVideo.Width, picVideo.Height '在图片控件中绘制捕获的图片
- Kill strTemp '删除捕获文件
- End If
- End With
- End Sub
- Private Sub txtOther_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then '若按回车键
- Call txtOther_Validate(False) '调用过程,完成显示比例设置
- ElseIf KeyAscii <= Asc("0") Or KeyAscii >= Asc("9") Then '若输入的不是0~9的数值
- KeyAscii = 0 '取消输入值
- End If
- End Sub
- Private Sub txtOther_Validate(Cancel As Boolean)
- timer1.Enabled = False '禁止时钟控件
- If Val(txtOther.Text) = 0 Then txtOther.Text = 100 '若输入的值非法,设置其值为100
- picVideo.Width = frmCamera.ezVidCap1.Width * Val(txtOther.Text) / 100 '设置图片控件的宽度
- picVideo.Height = frmCamera.ezVidCap1.Height * Val(txtOther.Text) / 100 '设置图片控件的高度
- Frame1.Left = picVideo.Left + picVideo.Width + 200 '设置框架控件的坐标
- If Me.WindowState <> vbMaximized Then '若窗体不是最大化状态
- Me.Width = Frame1.Left + Frame1.Width + 400 '设置窗体宽度
- Me.Height = picVideo.Top + picVideo.Height + 800 '设置窗体高度
- If Me.Height < Frame1.Top + Frame1.Height + 800 Then '若窗体小于框架
- Me.Height = Frame1.Top + Frame1.Height + 800 '设置窗体的高度
- End If
- End If
- timer1.Enabled = True '允许时钟控件
- End Sub