- 新建工程,增加一个bas模块
- 加入一个MCI控件,一个command按钮和一个图片框,设置form的
ScaleMode property为 Pixels (3).
- .BAS 文件代码:
Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypeType MCI_OVLY_RECT_PARMSdwCallback As Longrc As RECTEnd TypeGlobal Const MCI_OVLY_WHERE_SOURCE = &H20000Global Const MCI_OVLY_WHERE_DESTINATION = &H40000Global Const MCI_WHERE = &H843Declare Function mciSendCommand Lib "winmm.dll" _Alias "mciSendCommandA" ( _ByVal wDeviceID As Long, _ByVal uMessage As Long, _ByVal dwParam1 As Long,dwParam2 As Any) As LongDeclare Function mciGetErrorString Lib "winmm.dll" _Alias "mciGetErrorStringA" ( _ByVal dwError As Long, _ByVal lpstrBuffer As String, _ByVal uLength As Long) As Long
Command1_Click()事件: Sub Command1_Click ()Const MB_OK = 0Const MB_ICONSTOP = 16Dim Retval&, Buffer$Dim dwParam2 As MCI_OVLY_RECT_PARMSMMControl1.Command = "Close"MMControl1.Filename = "WndSurf1.avi"'
MMControl1.hWndDisplay = Picture1.hWndMMControl1.Command = "Open"'初始化
dwParam2.dwCallback = MMControl1.hWnddwParam2.rc.Left = 0dwParam2.rc.Top = 0dwParam2.rc.Right = 0dwParam2.rc.Bottom = 0'发送消息
Retval& = mciSendCommand(MMControl1.DeviceID, MCI_WHERE, MCI_OVLY_WHERE_SOURCE, dwParam2)If Retval& <> 0 Then'错误发生.Buffer$ = Space$(100)'Get a description of the error:Retval& = mciGetErrorString(Retval&, Buffer$, Len(Buffer$))MsgBox Trim$(Buffer$), MB_OK + MB_ICONSTOP, "ERROR"Else'改变picture box大小:Picture1.Width = dwParam2.rc.right - dwParam2.rc.leftPicture1.Height = dwParam2.rc.bottom - dwParam2.rc.top'播放电影
MMControl1.Wait = True ' Wait for the next command to completeMMControl1.Command = "play" 'Play the video clipMMControl1.Command = "close"End IfEnd Sub
- 按f5运行程序
|