|
-
Oct 28th, 2009, 05:19 PM
#1
Thread Starter
Lively Member
Progress bar problem
Hi all i`m trying to use a progress bar while i click a button to start my web cam.
It needs about 2-3 seconds to display the web cam capture image in my picture box.
When i use the following code the progress bar starts only when the capture image is displayed in my picture box, it waits those seconds to start.
What can i do about that problem?
Code:
Private Sub TimerProgreesBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerProgreesBar.Tick
If ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Visible = False
TimerProgreesBar.Enabled = False
Else
ProgressBar1.Value = ProgressBar1.Value + 10
End If
End Sub
-
Oct 28th, 2009, 05:30 PM
#2
Re: Progress bar problem
Could you show the complete code please...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 28th, 2009, 05:31 PM
#3
Addicted Member
Re: Progress bar problem
Your thread is blocked with the call to capCreateCaptureWindowA (or however you're doing it) I think you're going to need another thread to display the update information.
Last edited by 7777; Oct 28th, 2009 at 05:32 PM.
Reason: spelling
-
Oct 28th, 2009, 05:37 PM
#4
Thread Starter
Lively Member
Re: Progress bar problem
Ok heres how i set up camera
Code:
Public Sub startCam(ByVal parentH As Integer)
window_handle1 = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, OutputWidth, CShort(OutputHeight), parentH, 0)
If setCam() = False Then
MessageBox.Show("Error setting Up Camera")
End If
End Sub
Code:
Private Function setCam() As Boolean
'Sets all the camera up
If SendMessage(window_handle2, WM_CAP_DRIVER_CONNECT, 0, 0) Then
SendMessage(window_handle2, WM_CAP_SET_PREVIEWRATE, 10, 0)
SendMessage(window_handle2, WM_CAP_SET_PREVIEW, True, 0)
isRunning = True
Return True
Else
isRunning = False
Return False
End If
End Function
On start button click the progress bar should start but it doesn`t it waits to display the image from the web cam and then to fill.
-
Oct 28th, 2009, 05:49 PM
#5
Junior Member
Re: Progress bar problem
I don't see where the timer is enabled -- apprently when the button is clicked? You might try putting Application.DoEvents() right after the timer is enabled, and before the call to startcam.
-
Oct 29th, 2009, 07:20 AM
#6
Thread Starter
Lively Member
Re: Progress bar problem
Why is still doesn`t work? Do i need to include something else?
Here`s how i activate timerProgreesBar
Code:
Private Sub strcam_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles strcam.Click
TimerProgreesBar.Enabled = True
Application.DoEvents()
mycam.startCam(PictureBox1.Handle.ToInt32)
End sub
Here`s the timer
Code:
Private Sub TimerProgreesBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerProgreesBar.Tick
If ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Visible = False
TimerProgreesBar.Enabled = False
Else
ProgressBar1.Value = ProgressBar1.Value + 10
End If
End Sub
The progress bar start when the web cam image appears in the picturebox, it stills waits the web cam to connected...
-
Oct 29th, 2009, 07:36 AM
#7
Re: Progress bar problem
This works for me... There is a part in the code which I haven't tried and I have indicated that...
vb Code:
Public Class Form1 Private Sub btnGo_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnGo.Click ProgressBar1.Step = 10 ProgressBar1.Value = 0 TimerProgreesBar.Enabled = True '~~> Haven't tried this part mycam.startCam (PictureBox1.Handle.ToInt32) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.PerformStep() If ProgressBar1.Value >= ProgressBar1.Maximum Then TimerProgreesBar.Enabled = False End If End Sub End Class
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 29th, 2009, 03:25 PM
#8
Addicted Member
Re: Progress bar problem
I said before I think your mainUI thread is blocked by the api calls, I could be wrong, through. Perhaps a hack it would probably be an easier solution than figuring out the multithreading, you could just use a animated gif make it visible before the call then set visibility to false after the call completes. Since your progress bar is not really measuring progress only time elapsed, I dont think that it really matters, as long as the user knows its "working"
google "ajax animated loading gif"
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
|