Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Everyone,

I am working on a project where there are 2 forms with webcam programs.
The webcam is used just to preview a scene on a picturebox.
The problem is
Suppose form1 and form2 are used to implement webcam features. when I run form1 it works perfectly well..but when I switch to form2, it asks to choose a video source and then the picturebox displays black colour.
And if I run form2 first it works well but now the same thing happens to form1.

What may be the problem??
Do I have to clear some buffer??
How should I do it??
please help

this is the code used

VB
Private Sub OpenPreviewWindow()
       Dim piccapture As PictureBox = PictureBox1
       Dim iHeight As Integer = piccapture.Height
       Dim iWidth As Integer = piccapture.Width
       hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _480, piccapture.Handle.ToInt32, 0)

       If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then

           SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)

           SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)

           SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
           SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, piccapture.Width, piccapture.Height, _SWP_NOMOVE Or SWP_NOZORDER)


       End If


   End Sub



I also used Clipboard.clear()
but even this dint solve it..
Please help..
Posted
Comments
Ezra Neil 13-May-13 4:42am    
My guess is once the device established connection (you previewing the picture), it will not accept another connection asking for the same thing. In other words no sharing.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900