Click here to Skip to main content
11,928,919 members (45,496 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
I am using Visual Basic 2010. Trying to reliably capture webcam images. It works some times - but about 50% of the time it pops up and asks for the video source. Even after this popup it only works sporatically.

Platform Windows 7 32bit, Vusial Basic 2010

Here is a sample of my code - taken from the examples posted on the web.

Private Sub OpenForm()
           Dim iHeight As Integer = Privew.Height
           Dim iWidth As Integer = Privew.Width
           ' Open Preview window in picturebox
           hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
               480, Privew.Handle.ToInt32, 0)
           ' Connect to device
           If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
               'Set the preview scale
               SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
               'Set the preview rate in milliseconds
               SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
               'Start previewing the image from the camera
               SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
               ' Resize window to fit in picturebox
               SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, Privew.Width, Privew.Height, _
                       SWP_NOMOVE Or SWP_NOZORDER)
           End If
       Catch ex As Exception
       End Try

It only works occasionally - many times asking me for the 'Video Source' before it may or maynot show the image.

if any one know help me
Thanx in Advance
Posted 17-Dec-12 21:10pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

what dll are you using for capture the webcam image ?
MinhajAli 18-Dec-12 6:38am
I am using Avicap32.dll

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100