争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

Visual Basic 5.0中完成视频画中画

时间:2024/7/11作者:未知来源:争怎路由网人气:

在VISUAL BAISC 5.0中可以使用播放视频动画文件(*.AVI)的方法在我们的软件中加入动画效果,但在软件中如何实现视频画中画的效果呢?经笔者摸索,发现利用WIDOWS 95的API函数mciExecute、mciSendString和SetWindowPos可实现这一效果。

下面笔者以最常用的大画面中叠加小画面为例来说明视频画中画的实现方法。

一、建立窗体。进入VISUAL BAISC 5.0系统环境,建立一个新的窗体FORM1。

二、建立视频窗口。在这里笔者使用了一大一小的两个图画框(PictureBox)作为视频窗口。选择控件工具箱中的PictureBox控件,在窗体中拉出两个方框(Picture1和Picture2)。其中Picture1为大画面,播放AVI01.AVI文件;Picture2为小画面,播放AVI02.AVI文件。

三、编写相应控件的脚本。

通用模块:

Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long

Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String,ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

FORM1的ACTIVATE过程:

Dim AA As Long

Dim PlayAvi As Long

Dim tmpVal As String

Dim KeyValSize As Long

On Error Resume Next

tmpVal = String$(1024, 0)

KeyValSize = 1024

PlayAvi = mciSendString("STATUS AVI01 READY" + Str(Picture2.hwnd),tmpVal, KeyValSize, 0)

If PlayAvi <> 263 Then

PlayAvi = mciExecute("close AVI01")

End If

tmpVal = String$(1024, 0)

KeyValSize = 1024

PlayAvi = mciSendString("OPEN AVI01.AVI ALIAS AVI01 TYPE AVIVIDEO STYLE CHILD PARENT " + Str(Picture2.hwnd) + " WAIT", tmpVal, KeyValSize, 0)

x1Pos = Picture1.Width

y1Pos = Picture1.Height

tmpVal = String$(1024, 0)

KeyValSize = 1024

AA = mciSendString("STATUS AVI01 WINDOW HANDLE WAIT", tmpVal, KeyValSize, 0)

If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then

tmpVal = Left(tmpVal, KeyValSize - 1)

Else

tmpVal = Left(tmpVal, KeyValSize)

End If

AA = SetWindowPos(tmpVal, 0, 0, 0, x1Pos, y1Pos, 0)

AA = mciExecute("WINDOW AVI01 STATE SHOW")

tmpVal = String$(1024, 0)

KeyValSize = 1024

PlayAvi = mciSendString("STATUS AVI02 READY" + Str(Picture1.hwnd), tmpVal, KeyValSize, 0)

If PlayAvi <> 263 Then

PlayAvi = mciExecute("CLOSE AVI02")

End If

tmpVal = String$(1024, 0)

KeyValSize = 1024

PlayAvi = mciSendString("OPEN AVI02.AVI ALIAS AVI02 TYPE AVIVIDEO STYLE CHILD PARENT " + Str(Picture1.hwnd) + " WAIT", tmpVal, KeyValSize, 0)

x1Pos = Picture2.Width

y1Pos = Picture2.Height

tmpVal = String$(1024, 0)

KeyValSize = 1024

AA = mciSendString("STATUS AVI02 WINDOW HANDLE WAIT", tmpVal, KeyValSize, 0)

If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then

tmpVal = Left(tmpVal, KeyValSize - 1)

Else

tmpVal = Left(tmpVal, KeyValSize)

End If

AA = SetWindowPos(tmpVal, 0, 0, 0, x1Pos, y1Pos, 0)

MciExecute "WINDOW AVI02 STATE SHOW"

MciExecute "PLAY AVI01 REPEAT"

MciExecute "PLAY AVI02 REPEAT"

On Error GoTo 0

FORM1的QueryUnload过程:

mciExecute "STOP AVI01"

mciExecute "STOP AVI02"

mciExecute "CLOSE AVI01"

mciExecute "CLOSE AVI02"

运行此程序可见两个动画同时播放,实现了视频画中画的效果。以上程序在VISUAL BAISC 5.0及WINDOWS 95中运行通过。 

关键词:Visual Basic 5.0中完成视频画中画




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版