Results 1 to 6 of 6

Thread: Variable Not Being Set.. - Resolved

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved 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:
    1. Public Sub initCam(ByVal parentH As Integer)
    2.         frmViewer = New frmMain
    3.         MessageBox.Show(Me.iRunning) 'dubug purpose
    4.  
    5.         If Me.iRunning = True Then 'not working....
    6.             MessageBox.Show("Camera Is Already Running")
    7.             Exit Sub
    8.         Else
    9.  
    10.             hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 480, 360, parentH, 0)
    11.  
    12.  
    13.             If setCam() = False Then
    14.                 MessageBox.Show("Error setting Up Camera")
    15.             End If
    16.         End If
    17.     End Sub
    18.  
    19.  
    20.     Private Function setCam() As Boolean
    21.         If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
    22.             SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, CamFrameRate, 0)
    23.             SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
    24.             Me.iRunning = True ' here set to true....
    25.             Return True
    26.         Else
    27.             Me.iRunning = False
    28.             Return False
    29.         End If
    30.     End Function

    Any help or guidence on this? am i using variables incorrectly?
    Last edited by Pino; Jun 4th, 2005 at 03:42 PM.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Variable Not Being Set..

    How are you declaring the IsRunning variable?
    I don't live here any more.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Variable Not Being Set..

    VB Code:
    1. Public iRunning As Boolean

    Is this wrong?

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    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

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    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
  •  



Click Here to Expand Forum to Full Width