Click here to Skip to main content
13,400,775 members (34,044 online)
Rate this:
Please Sign up or sign in to 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

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 27-Apr-13 18:23pm
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180218.2 | Last Updated 27 Apr 2013
Copyright © CodeProject, 1999-2018
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