$IFNDEF __VFW_INC
$DEFINE __VFW_INC
$ENDIF
$IFNDEF TRUE
$DEFINE TRUE 1
$ENDIF
$IFNDEF FALSE
$DEFINE FALSE 0
$ENDIF
$IFNDEF __WIN32API
$IFNDEF __RQINC2
$DEFINE WM_USER &H400
$DEFINE WS_OVERLAPPED &H00000000
$DEFINE WS_CHILD &H40000000
$DEFINE WS_MINIMIZE &H20000000
$DEFINE WS_VISIBLE &H10000000
$DEFINE WS_DISABLED &H08000000
$DEFINE WS_MAXIMIZE &H01000000
$DEFINE WS_CAPTION &H00C00000
$DEFINE WS_BORDER &H00800000
$DEFINE WS_DLGFRAME &H00400000
$DEFINE WS_THICKFRAME &H00040000
$DEFINE WS_EX_DLGMODALFRAME &H00000001
$DEFINE WS_EX_NOPARENTNOTIFY &H00000004
$DEFINE WS_EX_TOPMOST &H00000008
$DEFINE WS_EX_TRANSPARENT &H00000020
$DEFINE WS_EX_TOOLWINDOW &H00000080
$DEFINE WS_EX_WINDOWEDGE &H00000100
$DEFINE WS_EX_CLIENTEDGE &H00000200
$DEFINE WS_EX_STATICEDGE &H00020000
$DEFINE WS_EX_APPWINDOW &H00040000
$DEFINE SWP_NOSIZE &H1
$DEFINE SWP_NOMOVE &H2
$DEFINE SWP_NOZORDER &H4
$DEFINE SWP_NOACTIVATE &H10
$DEFINE SWP_SHOWWINDOW &H40
$DEFINE SWP_NOSENDCHANGING &H400
DECLARE FUNCTION SendMessageAPI LIB "user32" ALIAS "SendMessageA" (BYVAL hwnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, lParam AS LONG) AS LONG
TYPE OPENFILENAME
lStructSize AS DWORD
hwndOwner AS LONG
hInstance AS LONG
lpstrFilter AS LONG
lpstrCustomFilter AS LONG
nMaxCustFilter AS DWORD
nFilterIndex AS DWORD
lpstrFile AS LONG
nMaxFile AS DWORD
lpstrFileTitle AS LONG
nMaxFileTitle AS DWORD
lpstrInitialDir AS LONG
lpstrTitle AS LONG
flags AS DWORD
nFileOffset AS SHORT
nFileExtension AS SHORT
lpstrDefExt AS LONG
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS LONG
END TYPE
$ENDIF
DECLARE FUNCTION DestroyWindow LIB "user32" ALIAS "DestroyWindow" (BYVAL hwnd AS LONG) AS LONG
TYPE BITMAPINFOHEADER
biSize AS LONG
biWidth AS LONG
biHeight AS LONG
biPlanes AS WORD
biBitCount AS WORD
biCompression AS LONG
biSizeImage AS LONG
biXPelsPerMeter AS LONG
biYPelsPerMeter AS LONG
biClrUsed AS LONG
biClrImportant AS LONG
END TYPE
TYPE BITMAPINFO
bmiHeader_biSize AS DWORD
bmiHeader_biWidth AS LONG
bmiHeader_biHeight AS LONG
bmiHeader_biPlanes AS WORD
bmiHeader_biBitCount AS WORD
bmiHeader_biCompression AS DWORD
bmiHeader_biSizeImage AS DWORD
bmiHeader_biXPelsPerMeter AS LONG
bmiHeader_biYPelsPerMeter AS LONG
bmiHeader_biClrUsed AS DWORD
bmiHeader_biClrImportant AS DWORD
bmiColors_rgbBlue AS BYTE
bmiColors_rgbGreen AS BYTE
bmiColors_rgbRed AS BYTE
bmiColors_rgbReserved AS BYTE
END TYPE
$ENDIF
Public CONST WM_CAP_START AS LONG = WM_USER
Public CONST WM_CAP_GET_CAPSTREAMPTR AS LONG = WM_CAP_START + 1
Public CONST WM_CAP_SET_CALLBACK_ERROR AS LONG = WM_CAP_START + 2
Public CONST WM_CAP_SET_CALLBACK_STATUS AS LONG = WM_CAP_START + 3
Public CONST WM_CAP_SET_CALLBACK_YIELD AS LONG = WM_CAP_START + 4
Public CONST WM_CAP_SET_CALLBACK_FRAME AS LONG = WM_CAP_START + 5
Public CONST WM_CAP_SET_CALLBACK_VIDEOSTREAM AS LONG = WM_CAP_START + 6
Public CONST WM_CAP_SET_CALLBACK_WAVESTREAM AS LONG = WM_CAP_START + 7
Public CONST WM_CAP_GET_USER_DATA AS LONG = WM_CAP_START + 8
Public CONST WM_CAP_SET_USER_DATA AS LONG = WM_CAP_START + 9
Public CONST WM_CAP_DRIVER_CONNECT AS LONG = WM_CAP_START + 10
Public CONST WM_CAP_DRIVER_DISCONNECT AS LONG = WM_CAP_START + 11
Public CONST WM_CAP_DRIVER_GET_NAME AS LONG = WM_CAP_START + 12
Public CONST WM_CAP_DRIVER_GET_VERSION AS LONG = WM_CAP_START + 13
Public CONST WM_CAP_DRIVER_GET_CAPS AS LONG = WM_CAP_START + 14
Public CONST WM_CAP_FILE_SET_CAPTURE_FILE AS LONG = WM_CAP_START + 20
Public CONST WM_CAP_FILE_GET_CAPTURE_FILE AS LONG = WM_CAP_START + 21
Public CONST WM_CAP_FILE_ALLOCATE AS LONG = WM_CAP_START + 22
Public CONST WM_CAP_FILE_SAVEAS AS LONG = WM_CAP_START + 23
Public CONST WM_CAP_FILE_SET_INFOCHUNK AS LONG = WM_CAP_START + 24
Public CONST WM_CAP_FILE_SAVEDIB AS LONG = WM_CAP_START + 25
Public CONST WM_CAP_EDIT_COPY AS LONG = WM_CAP_START + 30
Public CONST WM_CAP_SET_AUDIOFORMAT AS LONG = WM_CAP_START + 35
Public CONST WM_CAP_GET_AUDIOFORMAT AS LONG = WM_CAP_START + 36
Public CONST WM_CAP_DLG_VIDEOFORMAT AS LONG = WM_CAP_START + 41
Public CONST WM_CAP_DLG_VIDEOSOURCE AS LONG = WM_CAP_START + 42
Public CONST WM_CAP_DLG_VIDEODISPLAY AS LONG = WM_CAP_START + 43
Public CONST WM_CAP_GET_VIDEOFORMAT AS LONG = WM_CAP_START + 44
Public CONST WM_CAP_SET_VIDEOFORMAT AS LONG = WM_CAP_START + 45
Public CONST WM_CAP_DLG_VIDEOCOMPRESSION AS LONG = WM_CAP_START + 46
Public CONST WM_CAP_SET_PREVIEW AS LONG = WM_CAP_START + 50
Public CONST WM_CAP_SET_OVERLAY AS LONG = WM_CAP_START + 51
Public CONST WM_CAP_SET_PREVIEWRATE AS LONG = WM_CAP_START + 52
Public CONST WM_CAP_SET_SCALE AS LONG = WM_CAP_START + 53
Public CONST WM_CAP_GET_STATUS AS LONG = WM_CAP_START + 54
Public CONST WM_CAP_SET_SCROLL AS LONG = WM_CAP_START + 55
Public CONST WM_CAP_GRAB_FRAME AS LONG = WM_CAP_START + 60
Public CONST WM_CAP_GRAB_FRAME_NOSTOP AS LONG = WM_CAP_START + 61
Public CONST WM_CAP_SEQUENCE AS LONG = WM_CAP_START + 62
Public CONST WM_CAP_SEQUENCE_NOFILE AS LONG = WM_CAP_START + 63
Public CONST WM_CAP_SET_SEQUENCE_SETUP AS LONG = WM_CAP_START + 64
Public CONST WM_CAP_GET_SEQUENCE_SETUP AS LONG = WM_CAP_START + 65
Public CONST WM_CAP_SET_MCI_DEVICE AS LONG = WM_CAP_START + 66
Public CONST WM_CAP_GET_MCI_DEVICE AS LONG = WM_CAP_START + 67
Public CONST WM_CAP_STOP AS LONG = WM_CAP_START + 68
Public CONST WM_CAP_ABORT AS LONG = WM_CAP_START + 69
Public CONST WM_CAP_SINGLE_FRAME_OPEN AS LONG = WM_CAP_START + 70
Public CONST WM_CAP_SINGLE_FRAME_CLOSE AS LONG = WM_CAP_START + 71
Public CONST WM_CAP_SINGLE_FRAME AS LONG = WM_CAP_START + 72
Public CONST WM_CAP_PAL_OPEN AS LONG = WM_CAP_START + 80
Public CONST WM_CAP_PAL_SAVE AS LONG = WM_CAP_START + 81
Public CONST WM_CAP_PAL_PASTE AS LONG = WM_CAP_START + 82
Public CONST WM_CAP_PAL_AUTOCREATE AS LONG = WM_CAP_START + 83
Public CONST WM_CAP_PAL_MANUALCREATE AS LONG = WM_CAP_START + 84
Public CONST WM_CAP_SET_CALLBACK_CAPCONTROL AS LONG = WM_CAP_START + 85
TYPE VFWPOINT
x AS LONG
y AS LONG
END TYPE
TYPE CAPDRIVERCAPS
wDeviceIndex AS LONG
fHasOverlay AS LONG
fHasDlgVideoSource AS LONG
fHasDlgVideoFormat AS LONG
fHasDlgVideoDisplay AS LONG
fCaptureInitialized AS LONG
fDriverSuppliesPalettes AS LONG
hVideoIn AS LONG
hVideoOut AS LONG
hVideoExtIn AS LONG
hVideoExtOut AS LONG
END TYPE
TYPE CAPSTATUS
uiImageWidth AS LONG
uiImageHeight AS LONG
fLiveWindow AS LONG
fOverlayWindow AS LONG
fScale AS LONG
ptScroll_x AS LONG
ptScroll_y AS LONG
fUsingDefaultPalette AS LONG
fAudioHardware AS LONG
fCapFileExists AS LONG
dwCurrentVideoFrame AS LONG
dwCurrentVideoFramesDropped AS LONG
dwCurrentWaveSamples AS LONG
dwCurrentTimeElapsedMS AS LONG
hPalCurrent AS LONG
fCapturingNow AS LONG
dwReturn AS LONG
wNumVideoAllocated AS LONG
wNumAudioAllocated AS LONG
END TYPE
Public CONST AVSTREAMMASTER_AUDIO AS LONG = 0
Public CONST AVSTREAMMASTER_NONE AS LONG = 1
TYPE CAPTUREPARMS
dwRequestMicroSecPerFrame AS LONG
fMakeUserHitOKToCapture AS LONG
wPercentDropForError AS LONG
fYield AS LONG
dwIndexSize AS LONG
wChunkGranularity AS LONG
fUsingDOSMemory AS LONG
wNumVideoRequested AS LONG
fCaptureAudio AS LONG
wNumAudioRequested AS LONG
vKeyAbort AS LONG
fAbortLeftMouse AS LONG
fAbortRightMouse AS LONG
fLimitEnabled AS LONG
wTimeLimit AS LONG
fMCIControl AS LONG
fStepMCIDevice AS LONG
dwMCIStartTime AS LONG
dwMCIStopTime AS LONG
fStepCaptureAt2x AS LONG
wStepCaptureAverageFrames AS LONG
dwAudioBufferSize AS LONG
fDisableWriteCache AS LONG
AVStreamMaster AS LONG
END TYPE
TYPE CAPINFOCHUNK
fccInfoID AS LONG
lpData AS LONG
cbData AS LONG
END TYPE
TYPE VIDEOHDR
lpData AS LONG
dwBufferLength AS LONG
dwBytesUsed AS LONG
dwTimeCaptured AS LONG
dwUser AS LONG
dwFlags AS LONG
dwReserved(3) AS LONG
END TYPE
TYPE WAVEFORMATEX
wFormatTag AS WORD
nChannels AS WORD
nSamplesPerSec AS DWORD
nAvgBytesPerSec AS DWORD
nBlockAlign AS WORD
wBitsPerSample AS WORD
cbSize AS WORD
END TYPE
DECLARE FUNCTION capCreateCaptureWindow LIB "avicap32.dll" ALIAS "capCreateCaptureWindowA" _
(BYVAL lpszWindowName AS STRING, _
BYVAL dwStyle AS LONG, _
BYVAL x AS LONG, _
BYVAL y AS LONG, _
BYVAL nWidth AS LONG, _
BYVAL nHeight AS LONG, _
BYVAL hwndParent AS LONG, _
BYVAL nID AS LONG) AS LONG
DECLARE FUNCTION capGetDriverDescription LIB "avicap32.dll" ALIAS "capGetDriverDescriptionA" _
(BYVAL dwDriverIndex AS LONG, _
BYVAL lpszName AS STRING, _
BYVAL cbName AS LONG, _
BYVAL lpszVer AS STRING, _
BYVAL cbVer AS LONG) AS LONG
DECLARE FUNCTION GetOpenFileNamePreview LIB "msvfw32.dll" _
ALIAS "GetOpenFileNamePreviewA" (filestruct AS OPENFILENAME) AS LONG
PRIVATE DECLARE FUNCTION GetSaveFileNamePreview LIB "msvfw32.dll" _
ALIAS "GetSaveFileNamePreviewA" (filestruct AS OPENFILENAME) AS LONG
Public CONST IDS_CAP_BEGIN AS LONG = 300
Public CONST IDS_CAP_END AS LONG = 301
Public CONST IDS_CAP_INFO AS LONG = 401
Public CONST IDS_CAP_OUTOFMEM AS LONG = 402
Public CONST IDS_CAP_FILEEXISTS AS LONG = 403
Public CONST IDS_CAP_ERRORPALOPEN AS LONG = 404
Public CONST IDS_CAP_ERRORPALSAVE AS LONG = 405
Public CONST IDS_CAP_ERRORDIBSAVE AS LONG = 406
Public CONST IDS_CAP_DEFAVIEXT AS LONG = 407
Public CONST IDS_CAP_DEFPALEXT AS LONG = 408
Public CONST IDS_CAP_CANTOPEN AS LONG = 409
Public CONST IDS_CAP_SEQ_MSGSTART AS LONG = 410
Public CONST IDS_CAP_SEQ_MSGSTOP AS LONG = 411
Public CONST IDS_CAP_VIDEDITERR AS LONG = 412
Public CONST IDS_CAP_READONLYFILE AS LONG = 413
Public CONST IDS_CAP_WRITEERROR AS LONG = 414
Public CONST IDS_CAP_NODISKSPACE AS LONG = 415
Public CONST IDS_CAP_SETFILESIZE AS LONG = 416
Public CONST IDS_CAP_SAVEASPERCENT AS LONG = 417
Public CONST IDS_CAP_DRIVER_ERROR AS LONG = 418
Public CONST IDS_CAP_WAVE_OPEN_ERROR AS LONG = 419
Public CONST IDS_CAP_WAVE_ALLOC_ERROR AS LONG = 420
Public CONST IDS_CAP_WAVE_PREPARE_ERROR AS LONG = 421
Public CONST IDS_CAP_WAVE_ADD_ERROR AS LONG = 422
Public CONST IDS_CAP_WAVE_SIZE_ERROR AS LONG = 423
Public CONST IDS_CAP_VIDEO_OPEN_ERROR AS LONG = 424
Public CONST IDS_CAP_VIDEO_ALLOC_ERROR AS LONG = 425
Public CONST IDS_CAP_VIDEO_PREPARE_ERROR AS LONG = 426
Public CONST IDS_CAP_VIDEO_ADD_ERROR AS LONG = 427
Public CONST IDS_CAP_VIDEO_SIZE_ERROR AS LONG = 428
Public CONST IDS_CAP_FILE_OPEN_ERROR AS LONG = 429
Public CONST IDS_CAP_FILE_WRITE_ERROR AS LONG = 430
Public CONST IDS_CAP_RECORDING_ERROR AS LONG = 431
Public CONST IDS_CAP_RECORDING_ERROR2 AS LONG = 432
Public CONST IDS_CAP_AVI_INIT_ERROR AS LONG = 433
Public CONST IDS_CAP_NO_FRAME_CAP_ERROR AS LONG = 434
Public CONST IDS_CAP_NO_PALETTE_WARN AS LONG = 435
Public CONST IDS_CAP_MCI_CONTROL_ERROR AS LONG = 436
Public CONST IDS_CAP_MCI_CANT_STEP_ERROR AS LONG = 437
Public CONST IDS_CAP_NO_AUDIO_CAP_ERROR AS LONG = 438
Public CONST IDS_CAP_AVI_DRAWDIB_ERROR AS LONG = 439
Public CONST IDS_CAP_COMPRESSOR_ERROR AS LONG = 440
Public CONST IDS_CAP_AUDIO_DROP_ERROR AS LONG = 441
Public CONST IDS_CAP_STAT_LIVE_MODE AS LONG = 500
Public CONST IDS_CAP_STAT_OVERLAY_MODE AS LONG = 501
Public CONST IDS_CAP_STAT_CAP_INIT AS LONG = 502
Public CONST IDS_CAP_STAT_CAP_FINI AS LONG = 503
Public CONST IDS_CAP_STAT_PALETTE_BUILD AS LONG = 504
Public CONST IDS_CAP_STAT_OPTPAL_BUILD AS LONG = 505
Public CONST IDS_CAP_STAT_I_FRAMES AS LONG = 506
Public CONST IDS_CAP_STAT_L_FRAMES AS LONG = 507
Public CONST IDS_CAP_STAT_CAP_L_FRAMES AS LONG = 508
Public CONST IDS_CAP_STAT_CAP_AUDIO AS LONG = 509
Public CONST IDS_CAP_STAT_VIDEOCURRENT AS LONG = 510
Public CONST IDS_CAP_STAT_VIDEOAUDIO AS LONG = 511
Public CONST IDS_CAP_STAT_VIDEOONLY AS LONG = 512
FUNCTION capSetCallbackOnError(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnError = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_ERROR, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnStatus(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnStatus = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_STATUS, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnYield(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnYield = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_YIELD, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnFrame(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnFrame = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_FRAME, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnVideoStream(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnVideoStream = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnWaveStream(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnWaveStream = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0&, lpProc)
END FUNCTION
FUNCTION capSetCallbackOnCapControl(BYVAL hCapWnd AS LONG, BYVAL lpProc AS LONG) AS LONG
capSetCallbackOnCapControl = SendMessageAPI(hCapWnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0&, lpProc)
END FUNCTION
FUNCTION capSetUserData(BYVAL hCapWnd AS LONG, BYVAL lUser AS LONG) AS LONG
capSetUserData = SendMessageAPI(hCapWnd, WM_CAP_SET_USER_DATA, 0&, lUser)
END FUNCTION
FUNCTION capGetUserData(BYVAL hCapWnd AS LONG) AS LONG
capGetUserData = SendMessageAPI(hCapWnd, WM_CAP_GET_USER_DATA, 0&, 0&)
END FUNCTION
FUNCTION capDriverConnect(BYVAL hCapWnd AS LONG, BYVAL i AS LONG) AS LONG
capDriverConnect = SendMessageAPI(hCapWnd, WM_CAP_DRIVER_CONNECT, i, 0&)
END FUNCTION
FUNCTION capDriverDisconnect(BYVAL hCapWnd AS LONG) AS LONG
capDriverDisconnect = SendMessageAPI(hCapWnd, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
END FUNCTION
FUNCTION capDriverGetName(BYVAL hCapWnd AS LONG) AS STRING
DIM szBuffer AS STRING
szBuffer = STRING$(128, 0)
CALL SendMessageAPI(hCapWnd, WM_CAP_DRIVER_GET_NAME, 128, szBuffer)
capDriverGetName = LEFT$(szBuffer, INSTR(szBuffer, CHR$(0)) - 1)
END FUNCTION
FUNCTION capDriverGetVersion(BYVAL hCapWnd AS LONG) AS STRING
DIM szBuffer AS STRING
DIM retVal AS LONG
szBuffer = STRING$(128, 0)
retVal = SendMessageAPI(hCapWnd, WM_CAP_DRIVER_GET_VERSION, 128, szBuffer)
IF 0 <> retVal THEN
capDriverGetVersion = LEFT$(szBuffer, INSTR(szBuffer, CHR$(0)) - 1)
END IF
END FUNCTION
FUNCTION capDriverGetCaps(hCapWnd AS LONG, Caps AS CAPDRIVERCAPS, lSize AS LONG) AS LONG
capDriverGetCaps = SendMessageAPI(hCapWnd, WM_CAP_DRIVER_GET_CAPS, lSize, Caps)
END FUNCTION
FUNCTION capFileSetCaptureFile(BYVAL hCapWnd AS LONG, lpSzFileName AS LONG) AS LONG
capFileSetCaptureFile = SendMessageAPI(hCapWnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0&, lpSzFileName)
END FUNCTION
FUNCTION capFileGetCaptureFile(BYVAL hCapWnd AS LONG) AS STRING
DIM szBuffer AS STRING
DIM retVal AS LONG
szBuffer = STRING$(128, 0)
retVal = SendMessageAPI(hCapWnd, WM_CAP_FILE_GET_CAPTURE_FILE, 128, szBuffer)
IF retVal THEN
capFileGetCaptureFile = LEFT$(szBuffer, INSTR(szBuffer, CHR$(0)) - 1)
END IF
END FUNCTION
FUNCTION capFileAlloc(BYVAL hCapWnd AS LONG, BYVAL dwSize AS LONG) AS LONG
capFileAlloc = SendMessageAPI(hCapWnd, WM_CAP_FILE_ALLOCATE, 0&, dwSize)
END FUNCTION
FUNCTION capFileSaveAs(BYVAL hCapWnd AS LONG, BYVAL lpSzFilePath AS LONG) AS LONG
capFileSaveAs = SendMessageAPI(hCapWnd, WM_CAP_FILE_SAVEAS, 0&, lpSzFilePath)
END FUNCTION
FUNCTION capFileSetInfoChunk(BYVAL hCapWnd AS LONG, ByRef InfChunk AS CAPINFOCHUNK) AS LONG
capFileSetInfoChunk = SendMessageAPI(hCapWnd, WM_CAP_FILE_SET_INFOCHUNK, 0&, InfChunk)
END FUNCTION
FUNCTION capFileSaveDIB(BYVAL hCapWnd AS LONG, BYVAL lpSzFileName AS LONG) AS LONG
capFileSaveDIB = SendMessageAPI(hCapWnd, WM_CAP_FILE_SAVEDIB, 0&, lpSzFileName)
END FUNCTION
FUNCTION capEditCopy(BYVAL hCapWnd AS LONG) AS LONG
capEditCopy = SendMessageAPI(hCapWnd, WM_CAP_EDIT_COPY, 0&, 0&)
END FUNCTION
FUNCTION capSetAudioFormat(BYVAL hCapWnd AS LONG, ByRef wavFormat AS WAVEFORMATEX, BYVAL WavFormatSize AS LONG) AS LONG
capSetAudioFormat = SendMessageAPI(hCapWnd, WM_CAP_SET_AUDIOFORMAT, WavFormatSize, wavFormat)
END FUNCTION
FUNCTION capSetAudioFormatAsArray(BYVAL hCapWnd AS LONG, BYVAL wavFormat AS LONG, BYVAL WavFormatSize AS LONG) AS LONG
capSetAudioFormatAsArray = SendMessageAPI(hCapWnd, WM_CAP_SET_AUDIOFORMAT, WavFormatSize, wavFormat)
END FUNCTION
FUNCTION capGetAudioFormat(BYVAL hCapWnd AS LONG, ByRef wavFormat AS WAVEFORMATEX, BYVAL WavFormatSize AS LONG) AS LONG
capGetAudioFormat = SendMessageAPI(hCapWnd, WM_CAP_GET_AUDIOFORMAT, WavFormatSize, wavFormat)
END FUNCTION
FUNCTION capGetAudioFormatAsArray(BYVAL hCapWnd AS LONG, BYVAL wavFormat AS LONG, BYVAL WavFormatSize AS LONG) AS LONG
capGetAudioFormatAsArray = SendMessageAPI(hCapWnd, WM_CAP_GET_AUDIOFORMAT, WavFormatSize, wavFormat)
END FUNCTION
FUNCTION capGetAudioFormatSize(BYVAL hCapWnd AS LONG) AS LONG
capGetAudioFormatSize = SendMessageAPI(hCapWnd, WM_CAP_GET_AUDIOFORMAT, 0&, 0&)
END FUNCTION
FUNCTION capDlgVideoFormat(BYVAL hCapWnd AS LONG) AS LONG
capDlgVideoFormat = SendMessageAPI(hCapWnd, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
END FUNCTION
FUNCTION capDlgVideoSource(BYVAL hCapWnd AS LONG) AS LONG
capDlgVideoSource = SendMessageAPI(hCapWnd, WM_CAP_DLG_VIDEOSOURCE, 0&, 0&)
END FUNCTION
FUNCTION capDlgVideoDisplay(BYVAL hCapWnd AS LONG) AS LONG
capDlgVideoDisplay = SendMessageAPI(hCapWnd, WM_CAP_DLG_VIDEODISPLAY, 0&, 0&)
END FUNCTION
FUNCTION capDlgVideoCompression(BYVAL hCapWnd AS LONG) AS LONG
capDlgVideoCompression = SendMessageAPI(hCapWnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0&, 0&)
END FUNCTION
FUNCTION capGetVideoFormat(BYVAL hCapWnd AS LONG, ByRef BmpFormat AS BITMAPINFO, BYVAL CapFormatSize AS LONG) AS LONG
capGetVideoFormat = SendMessageAPI(hCapWnd, WM_CAP_GET_VIDEOFORMAT, CapFormatSize, BmpFormat)
END FUNCTION
FUNCTION capGetVideoFormatSize(BYVAL hCapWnd AS LONG) AS LONG
capGetVideoFormatSize = SendMessageAPI(hCapWnd, WM_CAP_GET_VIDEOFORMAT, 0&, 0&)
END FUNCTION
FUNCTION capSetVideoFormat(BYVAL hCapWnd AS LONG, ByRef BmpFormat AS BITMAPINFO, BYVAL CapFormatSize AS LONG) AS LONG
capSetVideoFormat = SendMessageAPI(hCapWnd, WM_CAP_SET_VIDEOFORMAT, CapFormatSize, BmpFormat)
END FUNCTION
FUNCTION capPreview(BYVAL hCapWnd AS LONG, BYVAL f AS LONG) AS LONG
capPreview = SendMessageAPI(hCapWnd, WM_CAP_SET_PREVIEW, f, 0&)
END FUNCTION
FUNCTION capPreviewRate(BYVAL hCapWnd AS LONG, BYVAL wMS AS LONG) AS LONG
capPreviewRate = SendMessageAPI(hCapWnd, WM_CAP_SET_PREVIEWRATE, wMS, 0&)
END FUNCTION
FUNCTION capOverlay(BYVAL hCapWnd AS LONG, BYVAL f AS LONG) AS LONG
capOverlay = SendMessageAPI(hCapWnd, WM_CAP_SET_OVERLAY, -(f), 0&)
END FUNCTION
FUNCTION capPreviewScale(BYVAL hCapWnd AS LONG, BYVAL f AS LONG) AS LONG
capPreviewScale = SendMessageAPI(hCapWnd, WM_CAP_SET_SCALE, -(f), 0&)
END FUNCTION
FUNCTION capGetStatus(BYVAL hCapWnd AS LONG, ByRef capStat AS CAPSTATUS, wSize AS LONG) AS LONG
capGetStatus = SendMessageAPI(hCapWnd, WM_CAP_GET_STATUS, wSize, capStat)
END FUNCTION
FUNCTION capSetScrollPos(BYVAL hCapWnd AS LONG, ByRef pt AS VFWPOINT) AS LONG
capSetScrollPos = SendMessageAPI(hCapWnd, WM_CAP_SET_SCROLL, 0&, pt)
END FUNCTION
FUNCTION capGrabFrame(BYVAL hCapWnd AS LONG) AS LONG
capGrabFrame = SendMessageAPI(hCapWnd, WM_CAP_GRAB_FRAME, 0&, 0&)
END FUNCTION
FUNCTION capGrabFrameNoStop(BYVAL hCapWnd AS LONG) AS LONG
capGrabFrameNoStop = SendMessageAPI(hCapWnd, WM_CAP_GRAB_FRAME_NOSTOP, 0&, 0&)
END FUNCTION
FUNCTION capCaptureSequence(BYVAL hCapWnd AS LONG) AS LONG
capCaptureSequence = SendMessageAPI(hCapWnd, WM_CAP_SEQUENCE, 0&, 0&)
END FUNCTION
FUNCTION capCaptureSequenceNoFile(BYVAL hCapWnd AS LONG) AS LONG
capCaptureSequenceNoFile = SendMessageAPI(hCapWnd, WM_CAP_SEQUENCE_NOFILE, 0&, 0&)
END FUNCTION
FUNCTION capCaptureStop(BYVAL hCapWnd AS LONG) AS LONG
capCaptureStop = SendMessageAPI(hCapWnd, WM_CAP_STOP, 0&, 0&)
END FUNCTION
FUNCTION capCaptureAbort(BYVAL hCapWnd AS LONG) AS LONG
capCaptureAbort = SendMessageAPI(hCapWnd, WM_CAP_ABORT, 0&, 0&)
END FUNCTION
FUNCTION capCaptureSingleFrameOpen(BYVAL hCapWnd AS LONG) AS LONG
capCaptureSingleFrameOpen = SendMessageAPI(hCapWnd, WM_CAP_SINGLE_FRAME_OPEN, 0&, 0&)
END FUNCTION
FUNCTION capCaptureSingleFrameClose(BYVAL hCapWnd AS LONG) AS LONG
capCaptureSingleFrameClose = SendMessageAPI(hCapWnd, WM_CAP_SINGLE_FRAME_CLOSE, 0&, 0&)
END FUNCTION
FUNCTION capCaptureSingleFrame(BYVAL hCapWnd AS LONG) AS LONG
capCaptureSingleFrame = SendMessageAPI(hCapWnd, WM_CAP_SINGLE_FRAME, 0&, 0&)
END FUNCTION
FUNCTION capCaptureGetSetup(BYVAL hCapWnd AS LONG, ByRef capParms AS CAPTUREPARMS, S AS LONG) AS LONG
capCaptureGetSetup = SendMessageAPI(hCapWnd, WM_CAP_GET_SEQUENCE_SETUP, S, capParms)
END FUNCTION
FUNCTION capCaptureSetSetup(BYVAL hCapWnd AS LONG, capParms AS CAPTUREPARMS, S AS LONG) AS LONG
capCaptureSetSetup = SendMessageAPI(hCapWnd, WM_CAP_SET_SEQUENCE_SETUP, S, capParms)
END FUNCTION
FUNCTION capSetMCIDeviceName(BYVAL hCapWnd AS LONG, BYVAL lpDeviceName AS LONG) AS LONG
capSetMCIDeviceName = SendMessageAPI(hCapWnd, WM_CAP_SET_MCI_DEVICE, 0&, lpDeviceName)
END FUNCTION
FUNCTION capGetMCIDeviceName(BYVAL hCapWnd AS LONG) AS STRING
DIM dwSize AS LONG
DIM szBuffer AS STRING
dwSize = 128
szBuffer = STRING$(dwSize, 0)
CALL SendMessageAPI(hCapWnd, WM_CAP_GET_MCI_DEVICE, dwSize, szBuffer)
capGetMCIDeviceName = LEFT$(szBuffer, INSTR(szBuffer, CHR$(0)) - 1)
END FUNCTION
FUNCTION capPaletteOpen(BYVAL hCapWnd AS LONG, BYVAL lpSzFilePath AS LONG) AS LONG
capPaletteOpen = SendMessageAPI(hCapWnd, WM_CAP_PAL_OPEN, 0&, lpSzFilePath)
END FUNCTION
FUNCTION capPaletteSave(BYVAL hCapWnd AS LONG, BYVAL lpSzFilePath AS LONG) AS LONG
capPaletteSave = SendMessageAPI(hCapWnd, WM_CAP_PAL_SAVE, 0&, lpSzFilePath)
END FUNCTION
FUNCTION capPalettePaste(BYVAL hCapWnd AS LONG) AS LONG
capPalettePaste = SendMessageAPI(hCapWnd, WM_CAP_PAL_PASTE, 0&, 0&)
END FUNCTION
FUNCTION capPaletteAuto(BYVAL hCapWnd AS LONG, BYVAL iFrames AS LONG, BYVAL iColors AS LONG) AS LONG
IF iColors < 257 THEN
capPaletteAuto = SendMessageAPI(hCapWnd, WM_CAP_PAL_AUTOCREATE, iFrames, iColors)
ELSE
SHOWMESSAGE "Error in Color num -- capPaletteAuto"
END IF
END FUNCTION
FUNCTION capPaletteManual(BYVAL hCapWnd AS LONG, BYVAL f AS LONG, BYVAL iColors AS LONG) AS LONG
IF iColors < 257 THEN
capPaletteManual = SendMessageAPI(hCapWnd, WM_CAP_PAL_MANUALCREATE, -(f), iColors)
ELSE
SHOWMESSAGE "Error in Color num -- capPaletteAuto"
END IF
END FUNCTION
TYPE QWebCam EXTENDS QOBJECT
PUBLIC:
hCapWnd AS LONG
CamNum AS LONG
Left AS LONG
Top AS LONG
Width AS LONG
Height AS LONG
Overlay AS LONG
Init AS LONG
FrameBuffers AS LONG
ImageHeight AS LONG PROPERTY SET SetImageHeight
ImageWidth AS LONG PROPERTY SET SetImageWidth
BitCount AS WORD PROPERTY SET SetBitCount
Preview AS LONG PROPERTY SET SetPreview
Capture AS LONG PROPERTY SET SetCapture
FrameInterval AS WORD
FramesDropped AS LONG
CAPTION AS STRING
Tag AS LONG
FormStyle AS LONG
OnFrame AS LONG PROPERTY SET SetOnFrame
FUNCTION CamInit(Form AS QFORM) AS LONG
DIM rtn AS LONG
DIM DriverCaps AS CAPDRIVERCAPS
DIM MyCapParms AS CAPTUREPARMS
IF This.Init THEN EXIT FUNCTION
WITH This
.hCapWnd = capCreateCaptureWindow(.CAPTION, .FormStyle, .Left, .Top, .Width, .Height, Form.Handle, .tag)
IF .hCapWnd = 0 THEN
SHOWMESSAGE("Could not create capture window")
RESULT = 0
EXIT FUNCTION
END IF
capCaptureGetSetup(.hCapWnd, MyCapParms, SIZEOF(MyCapParms))
MyCapParms.dwRequestMicroSecPerFrame = .FrameInterval
MyCapParms.fYield = true
MyCapParms.wNumVideoRequested = This.FrameBuffers
MyCapParms.fCaptureAudio = false
MyCapParms.AVStreamMaster = AVSTREAMMASTER_NONE
IF capCaptureSetSetup(.hCapWnd, MyCapParms, SIZEOF(MyCapParms)) = 0 THEN SHOWMESSAGE "Set setup failed"
rtn = capDriverConnect (.hCapWnd, .CamNum)
IF rtn THEN
capDriverGetCaps(.hCapWnd, DriverCaps, SIZEOF (DriverCaps))
.Init = DriverCaps.fCaptureInitialized
.CamNum = DriverCaps.wDeviceIndex
.Overlay = DriverCaps.fHasOverlay
IF .Overlay THEN .Overlay = capOverlay(.hCapWnd, True)
IF .Preview THEN
capPreviewRate(.hCapWnd, .FrameInterval)
.Preview = capPreview(.hCapWnd, True)
END IF
IF (.OnFrame <> 0) THEN
IF capSetCallbackOnFrame(This.hCapWnd, This.OnFrame) = 0 THEN SHOWMESSAGE "Frame Callback Error"
END IF
ELSE
SHOWMESSAGE("Could not connect to Camera")
END IF
END WITH
RESULT = rtn
END FUNCTION
SUB SetOnFrame(TheCallBackAddr AS LONG)
This.OnFrame = TheCallBackAddr
IF This.Init THEN
IF capSetCallbackOnFrame(This.hCapWnd, This.OnFrame) = 0 THEN SHOWMESSAGE "Frame Callback Error"
END IF
END SUB
FUNCTION SetImageHeight (TheImageHeight AS LONG) AS LONG
DIM VideoFormat AS BITMAPINFO
DIM SzbmpInfo AS DWORD: SzbmpInfo = SIZEOF(VideoFormat)
IF TheImageHeight > 0 THEN
This.ImageHeight = TheImageHeight
IF This.Init THEN
SzbmpInfo = capGetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo)
IF SzbmpInfo = 0 THEN RESULT = 0: EXIT FUNCTION
VideoFormat.bmiHeader_biSize = SzbmpInfo
VideoFormat.bmiHeader_biHeight = TheImageHeight
IF capSetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo) THEN
This.ImageHeight = TheImageHeight
RESULT = TheImageHeight
END IF
END IF
END IF
END FUNCTION
SUB SetImageWidth (TheImageWidth AS LONG) AS LONG
DIM VideoFormat AS BITMAPINFO
DIM SzbmpInfo AS DWORD: SzbmpInfo = SIZEOF(VideoFormat)
IF TheImageWidth > 0 THEN
This.ImageWidth = TheImageWidth
IF This.Init THEN
SzbmpInfo = capGetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo)
IF SzbmpInfo = 0 THEN RESULT = 0: EXIT SUB
VideoFormat.bmiHeader_biSize = SzbmpInfo
VideoFormat.bmiHeader_biWidth = TheImageWidth
IF capSetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo) THEN
This.ImageWidth = TheImageWidth
RESULT = TheImageWidth
END IF
END IF
END IF
END SUB
FUNCTION SetBitCount (TheBitCount AS WORD) AS WORD
DIM VideoFormat AS BITMAPINFO
DIM SzbmpInfo AS DWORD: SzbmpInfo = SIZEOF(VideoFormat)
RESULT = 0
IF TheBitCount > 0 THEN
IF This.Init THEN
SzbmpInfo = capGetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo)
IF SzbmpInfo = 0 THEN RESULT = 0: EXIT FUNCTION
VideoFormat.bmiHeader_biSize = SzbmpInfo
VideoFormat.bmiHeader_biBitCount = TheBitCount
IF capSetVideoFormat(This.hCapWnd, VideoFormat, SzbmpInfo) THEN
This.BitCount = TheBitCount
RESULT = TheBitCount
END IF
END IF
END IF
END FUNCTION
FUNCTION GetStatus() AS LONG
DIM CapStats AS CAPSTATUS
WITH This
RESULT = 0
IF capGetStatus(.hCapWnd, CapStats, SIZEOF(CapStats)) THEN
.ImageHeight = CapStats.uiImageHeight
.ImageWidth = CapStats.uiImageWidth
.FramesDropped = CapStats.dwCurrentVideoFramesDropped
.Overlay = CapStats.fOverlayWindow
.Preview = CapStats.fLiveWindow
RESULT = True
END IF
END WITH
END FUNCTION
SUB ShowDialogBox(TheBoxNum)
DIM WasCapturing AS LONG
DIM DriverCaps AS CAPDRIVERCAPS
WasCapturing = False
IF TheBoxNum THEN
IF This.Capture THEN
WasCapturing = True
This.Capture = False
END IF
IF This.Init = False THEN
capDriverGetCaps(This.hCapWnd, DriverCaps, SIZEOF (DriverCaps))
END IF
SHOWMESSAGE STR$(DriverCaps.fHasDlgVideoFormat)
SELECT CASE TheBoxNum
CASE 1
capDlgVideoFormat(This.hCapWnd)
CASE 2
IF DriverCaps.fHasDlgVideoSource THEN capDlgVideoSource(This.hCapWnd)
CASE 3
IF DriverCaps.fHasDlgVideoDisplay THEN capDlgVideoDisplay(This.hCapWnd)
CASE ELSE
capDlgVideoCompression(This.hCapWnd)
END SELECT
END IF
END SUB
SUB SetCapture(TheCaptureFlag AS LONG)
WITH This
.Capture = TheCaptureFlag
IF .Init THEN
IF .Capture THEN
.Capture = capCaptureSequenceNoFile(.hCapWnd)
IF .Overlay THEN .Overlay = capOverlay(.hCapWnd, True)
ELSE
IF .Overlay THEN .Overlay = capOverlay(.hCapWnd, False)
capCaptureStop(.hCapWnd)
END IF
END IF
END WITH
END SUB
SUB SetPreview(ThePreviewFlag AS LONG)
This.Preview = ThePreviewFlag
IF This.Init THEN
IF This.Preview THEN
capPreview(This.hCapWnd, True)
ELSE
capPreview(This.hCapWnd, 0&)
END IF
END IF
END SUB
SUB CleanUp
WITH This
IF .Init THEN
capPreview(.hCapWnd, 0&)
capSetCallbackOnFrame(.hCapWnd, 0&)
capCaptureStop(.hCapWnd)
capDriverDisconnect(.hCapWnd)
DestroyWindow(.hCapWnd)
.Init = False
END IF
END WITH
END SUB
FUNCTION GrabFrameToClipBoard() AS LONG
DIM i AS INTEGER
DIM T AS SINGLE
DIM info AS TBITMAP
DIM rtn AS LONG
DIM hBitmap AS LONG
DIM Bitmap1 AS QBITMAP
capEditCopy(This.hCapWnd)
IF clipboard.hasformat(CF_BITMAP) THEN
clipboard.OPEN
hBitmap=clipboard.GetAsHandle(CF_BITMAP)
clipboard.CLOSE
ELSE
SHOWMESSAGE "Cliboard is not in a valid format"
END IF
RESULT = GetObject(Bitmap1.Handle,SIZEOF(info),info)
RESULT = GetObject(hBitmap,SIZEOF(info),info)
END FUNCTION
FUNCTION SaveFrameToFile(TheFileName AS STRING) AS LONG
DIM TmpStr AS STRING
TmpStr = TheFileName
capGrabFrameNoStop(This.hCapWnd)
RESULT = capFileSaveDIB(This.hCapWnd, VARPTR(TmpStr))
END FUNCTION
SUB ReSize(TheForm AS QFORM)
DIM retVal AS LONG
DIM capStats AS CAPSTATUS
retVal = capGetStatus(This.hCapWnd, CapStats, SIZEOF(CapStats))
IF retVal THEN
CALL SetWindowPos(TheForm.Handle, _
0&, _
0&, _
0&, _
This.ImageWidth + (TheForm.Width - TheForm.ClientWidth), _
This.ImageHeight + (TheForm.Height - TheForm.ClientHeight),_
SWP_NOMOVE OR SWP_NOZORDER OR SWP_NOSENDCHANGING)
CALL SetWindowPos(This.hCapWnd, _
0&, _
0&, _
0&, _
This.ImageWidth, _
This.ImageHeight, _
SWP_NOMOVE OR SWP_NOZORDER OR SWP_NOSENDCHANGING)
capPreviewScale(This.hCapWnd, True)
END IF
END SUB
CONSTRUCTOR
CamNum = 0
Left = 0
Top = 0
Width = 240
Height = 200
OverLay = 0
Init = 0
FrameBuffers = 4
ImageHeight = This.SetImageHeight(This.Height)
ImageWidth = This.SetImageWidth(This.Width)
Capture = 0
FrameInterval = 16
FramesDropped = 0
Preview = True
CAPTION = "video"
Tag = 0
FormStyle = WS_CHILD OR WS_VISIBLE
END CONSTRUCTOR
END TYPE
SUB AddThisStuff
END SUB
|
|