|
Tipp 0077
|
ProgressBar in StatusBar
|
|
|
Autor/Einsender: Datum: |
|
Michael Werner 28.05.2005 |
|
Entwicklungsumgebung: |
|
VB.Net 2003 |
Framework: |
|
1.1 |
|
|
Die Fortschrittsanzeige wird innerhalb der Statusleiste, die als Container dient, angezeigt,
in dem die Parent-Eigenschaft der StatusBar an die ProgressBar
gebunden wird. Beim Start wird das Tick-Ereignis des Timers an seinen Event-Handler
gebunden und die Fortschrittsanzeige ausgelöst. In einer 2. Statusleiste wird der
Fortschritt in Prozent angezeigt und beim Erreichen des Maximalwertes ein Beep-Signal ausgelöst.
|
|
|
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private Declare Function Beep Lib "kernel32" (ByVal _
dwFreq As Int32, ByVal dwDuration As Int32) As Int32
Private MyTimer As New Timer
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Parent = StatusBar1
ProgressBar1.Dock = DockStyle.Fill
ProgressBar1.Maximum = 100
End Sub
Private Sub Initialize_MyTimer()
MyTimer.Interval = 100
AddHandler MyTimer.Tick, AddressOf IncreaseProgressBar
MyTimer.Start()
Me.Cursor = Cursors.WaitCursor
End Sub
Private Sub IncreaseProgressBar(ByVal sender As Object, _
ByVal e As EventArgs)
ProgressBar1.Increment(1)
StatusBar2.Text = ProgressBar1.Value.ToString() + "% Completed"
If ProgressBar1.Value = ProgressBar1.Maximum Then
MyTimer.Stop()
Me.Cursor = Cursors.Default
Dim intRet As Int32 = Beep(800, 100)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Initialize_MyTimer()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
ProgressBar1.Value = 0
StatusBar2.Text = "0"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
If MessageBox.Show("Programm beenden?", "Programm beenden?", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question) <> _
vbYes Then
e.Cancel = True
End If
End Sub
End Class
|
|
|
|
|
Windows-Version |
98/SE |
|
|
ME |
|
|
NT |
|
|
2000 |
|
|
XP |
|
|
Vista |
|
|
Win
7 |
|
|
|
|
Download (6,5
kB)
|
Downloads bisher: [ 892 ]
|
|
|