N
Nicolas
When I resize (Enlarge) the form while the progress bar is running the
rectangle drawing is not going to the end of the rectangle?
I got a form with one button, one statusbar with three statusbarpanel
Here is the code for help
What is wrong there?
#Region "ProgressBar"
Public Structure progresspanel
Dim x As Integer
Dim y As Integer
Dim Width As Integer
Dim Height As Integer
End Structure
Dim pb As Drawing.Drawing2D.LinearGradientBrush
Dim myProgressPanel As progresspanel
Dim g As Graphics
Dim rect As Rectangle
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim t As New Threading.Thread(AddressOf progress)
t.Start()
End Sub
Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As
System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem
myProgressPanel.x = sbdevent.Bounds.X
myProgressPanel.y = sbdevent.Bounds.Y
myProgressPanel.Width = sbdevent.Bounds.Width
myProgressPanel.Height = sbdevent.Bounds.Height
End Sub
Private Sub StatusBar1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles StatusBar1.Resize
StatusBar1.Invalidate(rect)
End Sub
Sub progress()
Dim i, j, w As Integer
j = 10000
g = Me.StatusBar1.CreateGraphics
For i = 0 To j
w = CInt((myProgressPanel.Width / j) * i)
If w = 0 Then w = 1
rect = New Rectangle(myProgressPanel.x, myProgressPanel.y, w,
myProgressPanel.Height)
pb = New Drawing.Drawing2D.LinearGradientBrush(rect, Color.AntiqueWhite,
Color.LightBlue, Drawing.Drawing2D.LinearGradientMode.Vertical)
g.FillRectangle(pb, rect)
g.DrawString(w.ToString, New Font("Arial", 10, FontStyle.Regular,
GraphicsUnit.Point), New SolidBrush(Color.Red), myProgressPanel.x,
myProgressPanel.y)
Me.StatusBar1.Panels(0).Text = w.ToString
Next
Me.StatusBar1.Panels(0).Text = "0"
g.Flush()
End Sub
#End Region
rectangle drawing is not going to the end of the rectangle?
I got a form with one button, one statusbar with three statusbarpanel
Here is the code for help
What is wrong there?
#Region "ProgressBar"
Public Structure progresspanel
Dim x As Integer
Dim y As Integer
Dim Width As Integer
Dim Height As Integer
End Structure
Dim pb As Drawing.Drawing2D.LinearGradientBrush
Dim myProgressPanel As progresspanel
Dim g As Graphics
Dim rect As Rectangle
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim t As New Threading.Thread(AddressOf progress)
t.Start()
End Sub
Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As
System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem
myProgressPanel.x = sbdevent.Bounds.X
myProgressPanel.y = sbdevent.Bounds.Y
myProgressPanel.Width = sbdevent.Bounds.Width
myProgressPanel.Height = sbdevent.Bounds.Height
End Sub
Private Sub StatusBar1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles StatusBar1.Resize
StatusBar1.Invalidate(rect)
End Sub
Sub progress()
Dim i, j, w As Integer
j = 10000
g = Me.StatusBar1.CreateGraphics
For i = 0 To j
w = CInt((myProgressPanel.Width / j) * i)
If w = 0 Then w = 1
rect = New Rectangle(myProgressPanel.x, myProgressPanel.y, w,
myProgressPanel.Height)
pb = New Drawing.Drawing2D.LinearGradientBrush(rect, Color.AntiqueWhite,
Color.LightBlue, Drawing.Drawing2D.LinearGradientMode.Vertical)
g.FillRectangle(pb, rect)
g.DrawString(w.ToString, New Font("Arial", 10, FontStyle.Regular,
GraphicsUnit.Point), New SolidBrush(Color.Red), myProgressPanel.x,
myProgressPanel.y)
Me.StatusBar1.Panels(0).Text = w.ToString
Next
Me.StatusBar1.Panels(0).Text = "0"
g.Flush()
End Sub
#End Region