• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

Visual Basic 5.0中实现视频画中画

发布: 2007-7-14 20:28 | 作者: 佚名    | 来源: 网络转载     | 查看: 46次 | 进入软件测试论坛讨论

领测软件测试网 在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中运行通过。 

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网