This program checks if webcam is available, if available then capture video and displays in picture box.
Add this code to the general module (.BAS file)
---------------------------------------------------------------------- - Public Const ws_child As Long = &H40000000
-
Public Const ws_visible As Long = &H10000000
-
-
Global Const WM_USER = 1024
-
Global Const wm_cap_driver_connect = WM_USER + 10
-
Global Const wm_cap_set_preview = WM_USER + 50
-
Global Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52
-
Global Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
-
Public Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
-
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
-
Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal a As String, ByVal b As Long, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Long, ByVal h As Integer) As Long
Add 4 command buttons and a picture box to the form
Add the following code to click en\vent of the respective buttons. -
'General Declaration
-
Dim hwdc As Long
-
Dim startcap As Boolean
-
-
Private Sub cmdCapture_Click()
-
Dim temp As Long
-
-
hwdc = capCreateCaptureWindow("Debasis Das", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
-
If (hwdc <> 0) Then
-
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
-
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
-
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
-
startcap = True
-
Else
-
MsgBox ("No Webcam found")
-
End If
-
End Sub
-
-
Private Sub cmdClose_Click()
-
Dim temp As Long
-
If startcap = True Then
-
temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
-
startcap = False
-
End If
-
End Sub
-
-
Private Sub cmdexit_Click()
-
Unload Me
-
End Sub
-
-
Private Sub cmdVideoFormat_Click()
-
Dim temp As Long
-
If startcap = True Then
-
temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
-
End If
-
End Sub
-
To achieve this two API function are used.
1. capCreateCaptureWindow
2. SendMessage
Please find the details of the functions for more info .
2 31512
I tried your Video Capture API/Program and it worked great...sort of. The first time I ran the code it worked fine. I exited the program and restarted it. Now I get nothing but a black picturebox and none of the other buttons work (except the EXIT Button). I am using VB 6 with Windows 7 (64). I'm lost. What is the problem? I only have one webcam attached to the computer.
If I restart my computer, this code works great the first time. Seems like something is not being reset when I exit the capture.
One other note..When I try to excute the code the second time (without a computer reboot) a "Video Source" box appears. Since I only have one webcam attached there is only one choice available. I press the "OK" button and the get the problem stated above.
Thanks,
Charles
Can this be modified to work in Access with VBA?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kanaiya |
last post by:
hello
i want to use DirectX.Net in c# i am done it. and capture video but i want
to take images from it how to do it. i am not found it please help me. bye.
--
With regards,
Gangani Kanaiya.
|
by: kantrishi |
last post by:
Can any body give me details how i would capture video stream through video camera and save it in my database/computer in windows media player format or in real plyaer.
I would like to make...
|
by: FMorales |
last post by:
We need to access to a webcam in .net c#
We need to show the video in a form from a web cam, and when push a buttom
record it to a file .....
How can we do it ??
Samples on google (c#...
|
by: Tsunami |
last post by:
Hi to all:
I have a big problem and I write to ask for help. Sorry if this message does
not arrive to the apropriate group. I have selected them paying attention
but I am not sure to do it well....
|
by: vmorikawa |
last post by:
Please, does anyone knows how to capture the video from webcam to a
webform ??
I found some examples but to Windows Forms.
I would like to make an application to see what's happen in my house...
|
by: aljosa |
last post by:
i'm trying to capture video from camera/webcam using python.
so far i haven't found any library that would allow me to do that.
cross-platform solution related to SDL/pygame would be nice but a...
|
by: Joseph Chase |
last post by:
Is there a cross-platform solution for video capture from a webcam?
I am aware of the Win32 videocapture library, but am unaware of how to
accomplish the same functionality on the Mac side.
...
|
by: chrisstorm |
last post by:
hi,
I know there are many examples and codes out there, I spent plenty of time searching around but still haven`t found what I am looking for (great - sounds like a song from U2).
I have to...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |