Hi Experts,Interesting finding, when comparing two dictionary of byte(),KeyNotFoundException throwed...
By alanwo_gmail_com
I'm thinking of purchasing a telnet emulation product written in vb.net, but I want to be able to ru...
By huffmaster
Could someone tell me how to rcord sound from a microphone and then playing it back using DirectX.Th...
By dawgfather
Hi there!I've got a question for you: I need to make an add-in function for anapplication, and t...
By fr_nk
Is it possible to return a form as the output from calling a webservice. In other words, could I cre...
By overstock_com_gmail_com, 1 Comments
Is it possible to return a form as the output from calling a webservice. In other words, could I cre...
By overstock_com_gmail_com, 1 Comments
Hi. :wave: This code work great for my Form...Private Sub Form1_KeyDown(ByVal sender As Object, ByV...
By mqmin, 5 Comments
good morning everyone i've got a question i am trying to use a button from the toolbox , all bu...
By xyz777, 7 Comments
Hey, I just have a quick question about Spy++(or similar programs like the one Joacim Andersson wrot...
By hiroshi, 2 Comments
If you're doing this as a learning experience then you'll want to learn how to do it yourself with GDI+. If you just want the effect then you might want to use the DoneOMeter control in the ElementsEx library (see my signature for link), which allows you to set an image to fill a progressbar.
jmcilhinney | Tues, 04 Dec 2007 14:31:00 GMT |
Here is an incredibly simple implementation.. one you can add timers to, and a better gradient fill using a graphics path.
Public Class GradientProgressBar
Inherits UserControl
Private _percent As Decimal = 0
Public Property Percent() As Integer
Get
Return Convert.ToInt32(_percent * 100)
End Get
Set(ByVal Value As Integer)
If (Value < 101) And (Value >= 0) Then
_percent = Convert.ToDecimal(Value / 100)
Me.Invalidate()
End If
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.DrawRectangle(Pens.Black, 0, 0, MyBase.Size.Width - 1, MyBase.Size.Height - 1)
e.Graphics.FillRectangle(New Drawing2D.LinearGradientBrush(New Point(1, 1), New Point(MyBase.Size.Width - 2, MyBase.Size.Height - 2), Color.Blue, Color.Teal), 1, 1, Convert.ToInt32((MyBase.Size.Width - 2) * _percent), MyBase.Size.Height - 2)
End Sub
End Class
'How to use it.
Dim p As New GradientProgressBar
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
p.Location = New Point(20, 20)
p.Size = New Size(200, 25)
Me.Controls.Add(p) 'Critical.
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim r As New Random
p.Percent = r.Next(0, 101)
End Sub
Bill
conipto | Tues, 04 Dec 2007 14:32:00 GMT |
Okies, I'll poke around with that.
My problem is not the drawing part, I have made a nice little progress bar before that showed the progress of an operation. The part I'm having trouble with is figuring out how to use a timer to dictate how long the progress bar runs.
Thanks both of ya :D
kal_torak | Tues, 04 Dec 2007 14:33:00 GMT |
So how do you know if the user is using a P90 with 32 megs of ram. Or using Norton Internet Security that slows their system to a crawl. Or has some spyware installed that makes the PC twice as slow.. etc..etc. You don't. All you know, from a programming perspective, is how complete your installation/event task is at various points. This is where you as a programmer make the thing make sense. For instance, if you were using my silly progress bar, and say at various points to change your taskbar. Simply having it work via a timer is an easy thing, though not very accurate considering the differences in people's programs.
For example, with my dumb little 5 minute control, to use a timer, you might go:
myGradientProgressBar.Percent = 100
Dim WithEvents T as new Timer
Private Sub Button1_click(blah) handles blah
T.Interval = 500
T.Start()
End Sub
Private Sub T_Tick (byval Sender as Object, ByVal e as EventArgs) Handles T.Tick
myGradientProgressBar.Percent -= 10
End Sub
So that every half a second, it counts down 10 percent. A better way, if used as an actual progress bar, is to at various points in your program change the percentage done value (which mine and nearly all progress bar controls you might find should have) and update the graphic. I.e, in stage one, you might complete what you estimate to be 10% of the work, so when it's complete you move to 10%, at stage 2, another 40% is completed, so you move the progress bar to 50%, etc, etc.. until your program finishes whatever it's doing.
Bill
conipto | Tues, 04 Dec 2007 14:34:00 GMT |