|
-
Jun 4th, 2005, 01:18 PM
#1
Thread Starter
PowerPoster
Variable Not Being Set.. - Resolved
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?
Last edited by Pino; Jun 4th, 2005 at 03:42 PM.
-
Jun 4th, 2005, 02:12 PM
#2
Re: Variable Not Being Set..
How are you declaring the IsRunning variable?
I don't live here any more.
-
Jun 4th, 2005, 02:47 PM
#3
Thread Starter
PowerPoster
Re: Variable Not Being Set..
VB Code:
Public iRunning As Boolean
Is this wrong?
-
Jun 4th, 2005, 03:04 PM
#4
Re: Variable Not Being Set..
No I was just wonderig if you had set an initial value to it at the same time. Never mind
I don't live here any more.
-
Jun 4th, 2005, 03:39 PM
#5
Re: Variable Not Being Set..
In your button click routine you are reinstantiating the mycam variable each time. That might be part of the problem.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 4th, 2005, 03:42 PM
#6
Thread Starter
PowerPoster
Re: Variable Not Being Set..
:-p how could i be so stupid.....
I havent tested it but i think your right....
I'm seting myCam as new iCam each time the button is clicked.... 
edit- YAY it works! 
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|