视频指定在在Picture1控件上播放,当Picture1大小随窗体大小变化而变化时,视频的播放该怎么实现适应Picture1大小变化???
以下是Picture1固定大小时,使视频适应Picture1固定大小时的代码,请问当我实现Picture1大小随窗体大小变化而变化时,这视频的播放该怎么实现适应Picture1大小变化???是在这段代码中来实现吗??非常感谢!!!Public Function PutMPEG(Left As Long, Top As Long, Width As Long, Height As Long) As StringDim dwReturn As Long
Dim ret As String * 255
If Width = 0 Or Height = 0 Then
Dim rec As RECT
Call GetWindowRect(Form1.Picture1.Hwnd, rec)
Width = rec.Right - rec.Left
Height = rec.Bottom - rec.Top
End IfdwReturn = mciSendString("put NOWMUSIC window at " & Left & " " & Top & " " & Width & " " & Height, 0&, 0&, 0&)
PutMPEG = "Success"
End FunctionPublic Function PlayMusic() As BooleanIf RefInt = 0 Then
Result = PutMPEG(Val(O), Val(0), Val(0), Val(0))
End If
End Function
以下是Picture1固定大小时,使视频适应Picture1固定大小时的代码,请问当我实现Picture1大小随窗体大小变化而变化时,这视频的播放该怎么实现适应Picture1大小变化???是在这段代码中来实现吗??非常感谢!!!Public Function PutMPEG(Left As Long, Top As Long, Width As Long, Height As Long) As StringDim dwReturn As Long
Dim ret As String * 255
If Width = 0 Or Height = 0 Then
Dim rec As RECT
Call GetWindowRect(Form1.Picture1.Hwnd, rec)
Width = rec.Right - rec.Left
Height = rec.Bottom - rec.Top
End IfdwReturn = mciSendString("put NOWMUSIC window at " & Left & " " & Top & " " & Width & " " & Height, 0&, 0&, 0&)
PutMPEG = "Success"
End FunctionPublic Function PlayMusic() As BooleanIf RefInt = 0 Then
Result = PutMPEG(Val(O), Val(0), Val(0), Val(0))
End If
End Function
解决方案 »
- VB语言编写的应用程序,怎么解决中、英、俄三种语言版本的问题
- 哈哈哈哈哈,方正县. 不解释.
- VB6开源了,你最希望大神们开发出什么新功能
- Recordset什么时候close
- 如何确定指定IP的计算机上是否运行着Sqlserver实例
- VB和sql2000 链接做成了以个管理系统~ 打包后可以在没有装VB和SQL的机器上运行吗?
- 请教:用DAO打开的数据库怎么在DataGrid中显示出来了?
- 求教如何将一个汉字转成相应的笔画
- 求助:我做了一个CD播放器,不能播放,请大家看看我的程序哪有错误!
- vb编写程序时怎么设定才能使程序运行是最大化显示啊?&另外怎么才能锁定窗口大小啊?
- 亲爱的VBer帮我看个问题吧!
- 代码改编
'Pict:图片框PictureBox
Public Function mciVideoStretch(ByVal MCIfile As String, Pict As PictureBox) 'MCI视频图像缩放函数
On Error Resume Next
Dim strMCI As String
strMCI = "put " & MCIfile & " window at 0 0 " & Pict.ScaleWidth & " " & Pict.ScaleHeight
Call mciSendString(strMCI, vbNullString, 0, 0)
End Function
Public Function PlayMusic() As Booleandim t as string
t=mciVideoStretch(MCIfile, Pict)End Function
可是好像没有效果???请问我是调用错了吗?求高手指点!!
非常感谢!请问一下,调用这函数时是这样写的吗?
Public Function PlayMusic() As Booleandim t as string
t=mciVideoStretch(MCIfile, Pict)End Function
可是好像没有效果???请问我是调用错了吗?求高手指点!!
call mciVideoStretch(MCIfile, Pict)
Private Sub Form_Resize()
Picture1.Move Form1.Left, Form1.Top, Form1.Width, Form1.Height
Call mciVideoStretch(MCIfile, Pict)
End Sub
大侠,在窗体的resize事件时,它说Call mciVideoStretch(MCIfile, Pict)中的“MCIfile”变量未定义
请问是什么原因???
Private Sub Form_Resize()
Picture1.Move Form1.Left, Form1.Top, Form1.Width, Form1.Height
Call mciVideoStretch(MCIfile, Picture1)
End Sub
Public Function PlayMusic() As Boolean
Dim RefInt As Long
PlayMusic = False
RefInt = mciSendString("play NOWMUSIC", vbNull, 0, 0)
If RefInt = 0 Then
PlayMusic = True: DownloadLrc
SetVolume ((MainForm.Button1(6).Left - 3250)) / 600 * 1000
End If
End FunctionPublic Function mciVideoStretch(ByVal MCIfile As String, Pict As PictureBox) 'MCI视频图像缩放函数
On Error Resume Next
Dim strMCI As String
strMCI = "put " & NOWMUSIC & " window at 0 0 " & Form1.Picture1.ScaleWidth & " " & Form1.Picture1.ScaleHeight
Call mciSendString(strMCI, vbNullString, 0, 0)
End Function
Form1的Resize事件
Private Sub Form_Resize()
PaintPicture Picbackbuf, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 0, 0, Picbackbuf.Width, Picbackbuf.Height
Picture1.Move 240, 450, Me.ScaleWidth - 490, Me.ScaleHeight - 600
Call mciVideoStretch(NOWMUSIC, Picture1)
End Sub
'窗体上放一个控件Picture1
Option Explicit
Private 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
Private Declare Function GetShortPathName Lib "kernel32.dll" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Const WS_CHILD As Long = &H40000000Dim MCIfile As String '要播放的多媒体文件名
Dim sMCI As String '转换后的短文件名'MCIfile:多媒体文件
'Pict:图片框PictureBox
'MCI视频图像缩放函数
Private Function mciVideoStretch(ByVal MCIfile As String, Pict As PictureBox)
On Error Resume Next
Dim strMCI As String
strMCI = "put " & MCIfile & " window at 0 0 " & Pict.ScaleWidth & " " & Pict.ScaleHeight
Call mciSendString(strMCI, vbNullString, 0, 0)
End FunctionPrivate Sub Form_Load()
Dim ErrorCode As Long, ReturnString As String
On Error Resume Next
Form1.ScaleMode = 3
Picture1.ScaleMode = 3
mciSendString "stop MEDIA", vbNullString, 0, 0
mciSendString "close MEDIA", vbNullString, 0, 0
MCIfile = "E:\其它\录像\永恒的吻_Vitas.avi" '事先加载一个多媒体文件
'将长文件名转换成短文件名,mciSendString不支持长文件名
sMCI = String(LenB(MCIfile), Chr(0))
GetShortPathName MCIfile, sMCI, Len(sMCI)
MCIfile = Left(sMCI, InStr(sMCI, Chr(0)) - 1)
'注意里面的格
ErrorCode = mciSendString("open " & Trim(MCIfile) & " Type " & "MPEGVideo" & _
" alias MEDIA parent " & Picture1.hWnd & " style " & WS_CHILD & " WAIT", ReturnString, 256, 0)
'开始播放
mciSendString "play MEDIA", vbNullString, 0, 0
End SubPrivate Sub Form_Resize()
Picture1.Move 0, 0, Form1.ScaleWidth, Form1.ScaleHeight
Call mciVideoStretch("MEDIA", Picture1)
End Sub'关闭窗体停止播放
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
mciSendString "stop MEDIA", vbNullString, 0, 0
mciSendString "close MEDIA", vbNullString, 0, 0
End Sub