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??
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)
I also used Clipboard.clear()
but even this dint solve it..