2012년 11월 12일 월요일
VB6 mciwndx.ocx (MCI Control)
1. MCIWNDX.OCX는 멀티미디어(WAV , AVI , Video ,기타자료)콘트롤로서 Multimedia API 함수인 mciSendCommand()를 통하여 제어 할 수 있다.
2.언어의 문제를 피하기 위하여 mciSendCommand 를 이용하여 사용한다.
Example>
1.Visual Basic 시작
2.MCIWNDX.ocx를 프로젝트에 추가
3.새로운 Module (Module1)을 프로젝트에 추가. General declarations section에 선언
Global Const MCI_STATUS = &H814
Global Const MCI_STATUS_ITEM = &H100&
Global Const MCI_STATUS_MODE = &H4&
Global Const MCI_STRING_OFFSET = 512
Global Const MCI_MODE_NOT_READY = (MCI_STRING_OFFSET + 12)
Global Const MCI_MODE_STOP = (MCI_STRING_OFFSET + 13)
Global Const MCI_MODE_PLAY = (MCI_STRING_OFFSET + 14)
Global Const MCI_MODE_RECORD = (MCI_STRING_OFFSET + 15)
Global Const MCI_MODE_SEEK = (MCI_STRING_OFFSET + 16)
Global Const MCI_MODE_PAUSE = (MCI_STRING_OFFSET + 17)
Global Const MCI_MODE_OPEN = (MCI_STRING_OFFSET + 18)
Type MCI_STATUS_PARMS
dwCallback As Long
dwReturn As Long
dwItem As Long
dwTrack As Long
End Type
Declare Function mciSendCommand Lib "mmsystem" _
(ByVal udeviceid As Integer, ByVal uMessage As Integer, _
ByVal dwParam1 As Long, dwParam2 As Any) As Long
4.아래 function을 module에 추가
Function GetMCIWndxMode(MCIControl As MCIWnd) As Long
Dim Info As MCI_STATUS_PARMS
Dim Ret As Long
Info.dwItem = MCI_STATUS_MODE
Info.dwCallback = 0
Info.dwTrack = 0
Ret = mciSendCommand(MCIControl.DeviceID,MCI_STATUS,MCI_STATUS_ITEM,Info)
GetMCIWndxMode = Info.dwReturn
End Function
5.command button (Command1)과 MCIWNDX control (MCIWnd1) 을 Form1에 추가.
6.Command1버튼에 아래와 같은 code를 입력.
Sub Command1_Click ()
Dim status As Long
' 아래의 Avi file을 사용자가 임의의 file을 지정
MCIWnd1.Filename = "c:\winnt35\clock.avi"
' 상태를 알아낸다
status = GetMCIWndxMode(MCIWnd1)
If status = MCI_MODE_STOP Then ' is it playing or stopped
Print "stopped"
End If
End Sub
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기