Ok i'm working on a Web Cam Class to get me going in .Net really.
I've hit a slight problem, when the user starts previewing the camera and all goes succesful I set a boolean variable to True (IRunning) so that if they click start again the routine will exit if iRunning is true. For some strange reason this isnt happening, i've spent an hour or so playing with it, here is the code.. and i've attacthed the app incase you need it.
VB Code:
Public Sub initCam(ByVal parentH As Integer) frmViewer = New frmMain MessageBox.Show(Me.iRunning) 'dubug purpose If Me.iRunning = True Then 'not working.... MessageBox.Show("Camera Is Already Running") Exit Sub Else hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 480, 360, parentH, 0) If setCam() = False Then MessageBox.Show("Error setting Up Camera") End If End If End Sub Private Function setCam() As Boolean If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, CamFrameRate, 0) SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0) Me.iRunning = True ' here set to true.... Return True Else Me.iRunning = False Return False End If End Function
Any help or guidence on this? am i using variables incorrectly?




Reply With Quote