i started this project in interest of a thread for taking ID photos
the code, using AMCAP, has been put together from many sources including research in msdn, and several other forums and is not original by me, i had trouble to make my webcam work, or select which cam to use if more than 1 was attached, there maybe better solutions than the way i have done it, but it works for me on XP home, with a generic webcam and a kodak dual mode camera.
i have used a timer to take a series (6) of snaps, which would allow the user, to select the best photo, to do whatever they wanted, as there seems to be no other code for webcams in the code bank i decided to post this project
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Nice work. This also works for me (XP pro with Logitech cam)
Please use the search function prior to posting a question and see if someone's already answered it.
-If I helped you, please rate me, as I'd do the same for you =)
-Remember to select the Resolved option for your post when you've gotten the answers you need.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
try savepicture picture1(index).picture, path & "\campic.bmp"
where index is the picture box you want to save and path is the folder to save in
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
desktop is not a vaild path
you would need the full path, something like, C:\Documents and Settings\ericeoh\Desktop
search in vb6 forum for code to return special folders
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
This thread is a little old, but I came across it trying to solve a problem using a built-in webcam (as opposed to external usb-connected), and now that my code finally works I thought I'd share it in case anyone out there is still looking....
[Originally posted to the thread "Re: WM_CAP_DRIVER_CONNECT connects but black window?", but added here by request from pete]
The problem I had was with code almost identical to that listed here, which worked fine with a USB-attached webcam, but not with a built-in device. I noticed that the SendMessage was always failing, but could find no versions of this code which actually investigate WHY it fails; all they ever do is just give up and destroy the capture window.
After many attempts to find the actual error, I noticed that *occasionally*, maybe 1 time in 10, the code did actually work, for no good reason.
I had to give up on finding the error, as the code got less and less stable the more error-handling code I put in. BUT, I finally put some retry code in, and the whole application burst into life and now works 100% reliably!
What fixed it for me was to replace the single IF SendMessage line with the following:
Code:
Dim connectAttempts As Integer = 0
While Not CBool(SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, 0, Nothing))
connectAttempts += 1
If connectAttempts > 10 Then
DestroyWindow(hHwnd)
Me.Cursor = Cursors.Default
Return False
End If
Threading.Thread.Sleep(1000)
End While
Hope this helps someone, as it cost me a couple of frustrating days getting this to work!
Ade
Last edited by lewisar; Dec 7th, 2011 at 09:31 AM.
Reason: Missing code tags