frmShow.frm
上传用户:szlwled
上传日期:2022-06-30
资源大小:95k
文件大小:9k
源码类别:

视频捕捉/采集

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{6BF52A50-394A-11D3-B153-00C04F79FAA6}#1.0#0"; "wmp.dll"
  3. Begin VB.Form frmShow 
  4.    AutoRedraw      =   -1  'True
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "回放"
  7.    ClientHeight    =   5070
  8.    ClientLeft      =   150
  9.    ClientTop       =   540
  10.    ClientWidth     =   7740
  11.    BeginProperty Font 
  12.       Name            =   "Arial"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   400
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    LinkTopic       =   "Form1"
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    ScaleHeight     =   5070
  24.    ScaleWidth      =   7740
  25.    StartUpPosition =   1  '所有者中心
  26.    Begin VB.CommandButton cmdDelete 
  27.       Caption         =   "删除"
  28.       BeginProperty Font 
  29.          Name            =   "宋体"
  30.          Size            =   9
  31.          Charset         =   134
  32.          Weight          =   400
  33.          Underline       =   0   'False
  34.          Italic          =   0   'False
  35.          Strikethrough   =   0   'False
  36.       EndProperty
  37.       Height          =   495
  38.       Left            =   1560
  39.       TabIndex        =   2
  40.       ToolTipText     =   "Delete current picture"
  41.       Top             =   4200
  42.       Width           =   1215
  43.    End
  44.    Begin VB.CommandButton cmdDeleteAll 
  45.       Caption         =   "删除所有"
  46.       BeginProperty Font 
  47.          Name            =   "宋体"
  48.          Size            =   9
  49.          Charset         =   134
  50.          Weight          =   400
  51.          Underline       =   0   'False
  52.          Italic          =   0   'False
  53.          Strikethrough   =   0   'False
  54.       EndProperty
  55.       Height          =   495
  56.       Left            =   2880
  57.       TabIndex        =   3
  58.       ToolTipText     =   "Delete all pictures"
  59.       Top             =   4200
  60.       Width           =   1215
  61.    End
  62.    Begin VB.ComboBox cmbType 
  63.       Height          =   330
  64.       Left            =   120
  65.       Style           =   2  'Dropdown List
  66.       TabIndex        =   0
  67.       Top             =   240
  68.       Width           =   2775
  69.    End
  70.    Begin VB.Timer timer1 
  71.       Enabled         =   0   'False
  72.       Interval        =   1000
  73.       Left            =   4800
  74.       Top             =   4320
  75.    End
  76.    Begin VB.CommandButton cmdPlay 
  77.       Caption         =   "循环图片"
  78.       Height          =   495
  79.       Left            =   240
  80.       TabIndex        =   1
  81.       ToolTipText     =   "Cycle through pictures"
  82.       Top             =   4200
  83.       Width           =   1215
  84.    End
  85.    Begin VB.CommandButton cmdClose 
  86.       Caption         =   "关闭"
  87.       Default         =   -1  'True
  88.       BeginProperty Font 
  89.          Name            =   "宋体"
  90.          Size            =   9
  91.          Charset         =   134
  92.          Weight          =   400
  93.          Underline       =   0   'False
  94.          Italic          =   0   'False
  95.          Strikethrough   =   0   'False
  96.       EndProperty
  97.       Height          =   495
  98.       Left            =   6120
  99.       TabIndex        =   5
  100.       ToolTipText     =   "Close detection log"
  101.       Top             =   4200
  102.       Width           =   1215
  103.    End
  104.    Begin VB.PictureBox pic1 
  105.       AutoRedraw      =   -1  'True
  106.       AutoSize        =   -1  'True
  107.       BackColor       =   &H80000005&
  108.       BeginProperty Font 
  109.          Name            =   "MS Sans Serif"
  110.          Size            =   8.25
  111.          Charset         =   0
  112.          Weight          =   400
  113.          Underline       =   0   'False
  114.          Italic          =   0   'False
  115.          Strikethrough   =   0   'False
  116.       EndProperty
  117.       Height          =   3600
  118.       Left            =   3120
  119.       ScaleHeight     =   3540
  120.       ScaleWidth      =   4260
  121.       TabIndex        =   6
  122.       TabStop         =   0   'False
  123.       ToolTipText     =   "Preview of picture"
  124.       Top             =   240
  125.       Width           =   4320
  126.    End
  127.    Begin VB.FileListBox filShow 
  128.       Height          =   3030
  129.       Left            =   120
  130.       Pattern         =   "motion_*.bmp"
  131.       TabIndex        =   4
  132.       Top             =   720
  133.       Width           =   2895
  134.    End
  135.    Begin WMPLibCtl.WindowsMediaPlayer wmp1 
  136.       Height          =   3615
  137.       Left            =   3120
  138.       TabIndex        =   7
  139.       Top             =   240
  140.       Width           =   3735
  141.       URL             =   ""
  142.       rate            =   1
  143.       balance         =   0
  144.       currentPosition =   0
  145.       defaultFrame    =   ""
  146.       playCount       =   1
  147.       autoStart       =   -1  'True
  148.       currentMarker   =   0
  149.       invokeURLs      =   -1  'True
  150.       baseURL         =   ""
  151.       volume          =   50
  152.       mute            =   0   'False
  153.       uiMode          =   "full"
  154.       stretchToFit    =   0   'False
  155.       windowlessVideo =   0   'False
  156.       enabled         =   -1  'True
  157.       enableContextMenu=   -1  'True
  158.       fullScreen      =   0   'False
  159.       SAMIStyle       =   ""
  160.       SAMILang        =   ""
  161.       SAMIFilename    =   ""
  162.       captioningID    =   ""
  163.       enableErrorDialogs=   0   'False
  164.       _cx             =   6588
  165.       _cy             =   6376
  166.    End
  167. End
  168. Attribute VB_Name = "frmShow"
  169. Attribute VB_GlobalNameSpace = False
  170. Attribute VB_Creatable = False
  171. Attribute VB_PredeclaredId = True
  172. Attribute VB_Exposed = False
  173. Option Explicit
  174. Private Sub cmbType_Click()
  175.     Select Case cmbType.ListIndex   '判断选中哪个类型
  176.         Case 0  '查看图片
  177.             filShow.Pattern = "*.BMP"   '设置过滤类型为BMP
  178.         Case 1  '查看视频
  179.             filShow.Pattern = "*.AVI"   '设置过滤类型为AVI
  180.     End Select
  181.     RefreshList '调用过程刷新文件列表
  182. End Sub
  183. Private Sub cmdClose_Click()    '关闭
  184.     wmp1.Close  '关闭MediaPlayer控件
  185.     Unload Me   '卸载窗体
  186. End Sub
  187. Private Sub cmdDelete_Click()   '删除
  188.     Dim intReply As Integer
  189.     intReply = MsgBox("确定想要删除 " & CStr(filShow.FileName) & "?", _
  190.         vbExclamation + vbYesNo, "警告")    '确认删除文件
  191.     If intReply = vbYes Then
  192.         Kill filShow.Path & "" & filShow.FileName  '执行删除操作
  193.     End If
  194.     RefreshList '调用过程刷新文件列表
  195. End Sub
  196. Private Sub cmdDeleteAll_Click()    '删除所有
  197.     Dim intReply As Integer
  198.     Dim i As Integer
  199.     intReply = MsgBox("确定想要全部删除所有文件?", vbExclamation + vbYesNo, "删除警告") '确认删除
  200.     
  201.     If intReply = vbYes Then
  202.         filShow.Refresh '刷新文件列表
  203.         For i = 0 To filShow.ListCount - 1  '循环处理列表中的每个文件
  204.             filShow.ListIndex = 0   '选中第1个文件
  205.             Kill filShow.Path & "" & filShow.FileName  '删除文件
  206.             filShow.Refresh '新刷文件列表
  207.         Next
  208.     End If
  209.     RefreshList '调用过程刷新文件列表
  210. End Sub
  211. Private Sub cmdPlay_Click() '循环显示图片
  212.     If cmdPlay.Caption = "循环图片" Then    '标题为“循环图片”
  213.         timer1.Enabled = True   '允许计时器
  214.         cmdPlay.Caption = "停止循环"    '修改按钮标题
  215.         cmdPlay.ToolTipText = "停止循环图片"    '修改按钮提示
  216.     Else
  217.         timer1.Enabled = False  '禁止计时器
  218.         cmdPlay.Caption = "循环图片"    '修改按钮标题
  219.         cmdPlay.ToolTipText = "循环图片"   '修改按钮提示
  220.     End If
  221. End Sub
  222. Private Sub filShow_Click() '单击列表框中的文件
  223.     Dim strFile As String
  224.     strFile = filShow.Path & "" & filShow.FileName '获取文件全路径名称
  225.     If cmbType.ListIndex = 0 Then   '显示图片
  226.         pic1.PaintPicture LoadPicture(strFile), 0, 0, pic1.Width, pic1.Height   '绘制图片
  227.     ElseIf cmbType.ListIndex = 1 Then   '查看视频
  228.         wmp1.URL = strFile  '设置播放文件
  229.         wmp1.Controls.play  '播放视频
  230.     End If
  231. End Sub
  232. Private Sub Form_Load()
  233.     On Error Resume Next
  234.     wmp1.Left = pic1.Left   '设置MediaPlayer控件坐标和尺寸
  235.     wmp1.Top = pic1.Top
  236.     wmp1.Width = pic1.Width
  237.     wmp1.Height = pic1.Height
  238.     wmp1.Visible = False
  239.     pic1.Visible = True
  240.     filShow.Path = App.Path & "TEMP"  '设置文件列表框的路径
  241.     filShow.Pattern = "*.BMP"   '设置安始显示文件类型
  242.     With cmbType
  243.         .Clear  '清空列表框
  244.         .AddItem "图片" '添加项目
  245.         .AddItem "视频"
  246.         cmbType.ListIndex = 0 '选择列表框中的第1项
  247.     End With
  248.     RefreshList '刷新列表
  249. End Sub
  250. Private Sub RefreshList()   '刷新图像列表
  251.     filShow.Refresh   '刷新列表
  252.     If cmbType.ListIndex = 0 Then '显示图片
  253.         cmdPlay.Enabled = True  '允许循环图片按钮
  254.         wmp1.Controls.stop  '停止播放视频
  255.         wmp1.Close  '关闭视频
  256.         wmp1.Visible = False    '隐藏MediaPlayer控件
  257.         pic1.Visible = True '显示图片控件
  258.         pic1.Picture = Me.Picture  '显示图片
  259.     ElseIf cmbType.ListIndex = 1 Then   '显示视频
  260.         cmdPlay.Enabled = False '禁止循环图片按钮
  261.         wmp1.Visible = True '显示MediaPlayer控件
  262.         pic1.Visible = False    '隐藏图片控件
  263.         timer1.Enabled = False  '禁止计时器
  264.     End If
  265.     If filShow.ListCount > 0 Then '有文件列表
  266.         cmdDelete.Enabled = True    '允行删除按钮
  267.         cmdDeleteAll.Enabled = True '允许全部删除按钮
  268.     Else
  269.         cmdDelete.Enabled = False    '禁止删除按钮
  270.         cmdDeleteAll.Enabled = False '禁止全部删除按钮
  271.     End If
  272. End Sub
  273. Private Sub timer1_Timer()
  274.     If filShow.ListIndex < (filShow.ListCount - 1) Then '显示下一个图片
  275.         filShow.ListIndex = filShow.ListIndex + 1
  276.     Else
  277.         timer1.Enabled = False '禁止时钟控件
  278.         cmdPlay.Caption = "循环图片"
  279.     End If
  280. End Sub