![]() |
|
Tipp 0180
|
Fortschrittsanzeige als Tortengrafik
|
 |
|
Autor/Einsender: Datum: |
|
Michael Werner 29.12.2001 |
|
| Entwicklungsumgebung: |
|
VB 6 |
|
|
|
Dieser Tipp zeigt, wie man mit Pi, 2 Winkeln und der Grafik-Methode Circle eine Tortengrafik erstellen und diese als Fortschrittsanzeige verwenden kann. Genauso gut können aber auch andere grafische Gegebenheiten, wie z.B. die
Laufwerksbelegung usw., angezeigt werden.
|
|
| |
Option Explicit
Dim Wert As Long
Dim Summe As Long
Dim Prozent As Single
Dim Pi As Single
Private Sub Form_Load()
With Picture1
.AutoRedraw = True
.FillStyle = 0
End With
Pi = Atn(1) * 4
Timer1.Interval = 1
Wert = 0
Summe = 1000
Prozent = Wert * 100 / Summe
Call TortenGrafik(Prozent)
End Sub
Private Sub TortenGrafik(Proz As Single)
Dim Winkel1 As Single
Dim Winkel2 As Single
Dim Radius As Long
Dim X As Long
Dim Y As Long
With Picture1
X = .Width / 2
Y = .Height / 2
Radius = 1000
.Cls
Picture1.Print CStr(Proz) & " %"
.FillColor = vbMagenta
Picture1.Circle (X, Y), Radius, 0
.FillColor = vbBlue
Winkel2 = -Pi / 2
Winkel1 = (-Pi * 0.02 * Proz) + Winkel2
If Winkel1 < -2 * Pi Then Winkel1 = Winkel1 + 2 * Pi
If Proz = 100 Then .FillColor = vbMagenta
Picture1.Circle (X, Y), Radius, 0, Winkel1, Winkel2
End With
End Sub
Private Sub cmdStart_Click()
If cmdStart.Caption = "&Start" Then
Timer1.Enabled = True
Wert = 0
cmdStart.Caption = "&Stop"
Else
Timer1.Enabled = False
cmdStart.Caption = "&Start"
End If
End Sub
Private Sub Timer1_Timer()
Wert = Wert + 2
Prozent = Wert * 100 / Summe
If Prozent = 100 Then
Timer1.Enabled = False
cmdStart.Caption = "&Start"
End If
Call TortenGrafik(Prozent)
End Sub
|
|
|
|
|
|
|
| Windows-Version |
| 95 |
 |
|
| 98/SE |
 |
|
| ME |
 |
|
| NT |
 |
|
| 2000 |
 |
|
| XP |
 |
|
| Vista |
 |
|
| Win
7 |
 |
|
|
| VB-Version |
| VBA 5 |
 |
|
| VBA 6 |
 |
|
| VB 4/16 |
 |
|
| VB 4/32 |
 |
|
| VB 5 |
 |
|
| VB 6 |
 |
|
|
|
Download (2,7 kB)
|
Downloads bisher: [ 2626 ]
|
|
|