| |

Fortgeschrittene ProgrammierungBeispiel MediaPlayer - ProgressBar | |  | Autor: Dieter (Moderator) | Datum: 06.03.02 13:14 |
| Hi Cromec,
ich habe mal eben etwas zusammengeschrieben:
<code><font color=#000099>Option</font> <font color=#000099>Explicit</font>
<font color=#000099>Private</font> <font color=#000099>Sub</font> _
Command1_Click()
<font color=#000099>With</font> MediaPlayer1
.FileName = "lied.mp3"
.Play
<font color=#000099>End</font> <font color=#000099>With</font>
<font color=#000099>End</font> <font color=#000099>Sub</font>
<font color=#000099>Private</font> <font color=#000099>Sub</font> _
MediaPlayer1_PlayStateChange(<font color=#000099>ByVal</font> OldState <font _
color=#000099>As</font> <font color=#000099>Long</font>, <font _
color=#000099>ByVal</font> NewState <font color=#000099>As</font> <font _
color=#000099>Long</font>)
<font color=green>' Status abfragen</font>
<font color=#000099>If</font> OldState = 0 <font color=#000099>And</font> _
NewState = 2 <font color=#000099>Then</font>
<font color=green>' Beginn neues Lied</font>
Timer1.Interval = 100
Timer1.Enabled = <font color=#000099>True</font>
<font color=#000099>Else</font>
Timer1.Enabled = <font color=#000099>False</font>
<font color=#000099>End</font> <font color=#000099>If</font>
<font color=#000099>End</font> <font color=#000099>Sub</font>
<font color=#000099>Private</font> <font color=#000099>Sub</font> Timer1_Timer()
<font color=#000099>With</font> MediaPlayer1
ShowProgress picProgress, Int(.CurrentPosition * 1000), 0, Int(.Duration * _
1000)
DoEvents
<font color=#000099>End</font> <font color=#000099>With</font>
<font color=#000099>End</font> <font color=#000099>Sub</font>
<font color=green>' Fortschritsanzeige</font>
<font color=#000099>Private</font> <font color=#000099>Sub</font> ShowProgress( _
picProgress <font color=#000099>As</font> PictureBox, _
<font color=#000099>ByVal</font> Value <font color=#000099>As</font> <font _
color=#000099>Long</font>, _
<font color=#000099>ByVal</font> Min <font color=#000099>As</font> <font _
color=#000099>Long</font>, _
<font color=#000099>ByVal</font> Max <font color=#000099>As</font> <font _
color=#000099>Long</font>, _
Optional <font color=#000099>ByVal</font> bShowProzent <font _
color=#000099>As</font> <font color=#000099>Boolean</font> = <font _
color=#000099>True</font>)
<font color=#000099>Dim</font> pWidth <font color=#000099>As</font> <font _
color=#000099>Long</font>
<font color=#000099>Dim</font> intProz <font color=#000099>As</font> <font _
color=#000099>Integer</font>
<font color=#000099>Dim</font> strProz <font color=#000099>As</font> <font _
color=#000099>String</font>
<font color=green>' Farben</font>
<font color=#000099>Const</font> progBackColor = &HC00000
<font color=#000099>Const</font> progForeColor = vbBlack
<font color=#000099>Const</font> progForeColorHighlight = vbWhite
<font color=green>' Plausibilitätsprüfungen</font>
<font color=#000099>If</font> Value < Min <font color=#000099>Then</font> _
Value = Min
<font color=#000099>If</font> Value > Max <font color=#000099>Then</font> _
Value = Max
<font color=green>' Prozentwert ausrechnen</font>
<font color=#000099>If</font> Max > 0 <font color=#000099>Then</font>
intProz = Int(Value / Max * 100 + 0.5)
<font color=#000099>Else</font>
intProz = 100
<font color=#000099>End</font> <font color=#000099>If</font>
<font color=#000099>With</font> picProgress
<font color=green>' Prüfen, ob AutoReadraw=True</font>
<font color=#000099>If</font> .AutoRedraw = <font _
color=#000099>False</font> <font color=#000099>Then</font> .AutoRedraw = _
<font color=#000099>True</font>
<font color=green>' Inhalt löschen</font>
picProgress.Cls
<font color=#000099>If</font> Value > 0 <font color=#000099>Then</font>
<font color=green>' Balkenbreite</font>
pWidth = .ScaleWidth / 100 * intProz
<font color=green>' Balken anzeigen</font>
picProgress.<font color=#000099>Line</font> (0, 0)-(pWidth, _
.ScaleHeight), _
progBackColor, <font color=#000099>BF</font>
<font color=green>' Prozentanzeige</font>
<font color=#000099>If</font> bShowProzent <font color=#000099>Then</font>
strProz = <font color=#000099>CStr</font>(intProz) & " %"
.CurrentX = (.ScaleWidth - .TextWidth(strProz)) / 2
.CurrentY = (.ScaleHeight - .TextHeight(strProz)) / 2
<font color=green>' Vordergrundfarbe</font>
<font color=#000099>If</font> pWidth >= .CurrentX <font _
color=#000099>Then</font>
.ForeColor = progForeColorHighlight
<font color=#000099>Else</font>
.ForeColor = progForeColor
<font color=#000099>End</font> <font color=#000099>If</font>
picProgress.<font color=#000099>Print</font> strProz
<font color=#000099>End</font> <font color=#000099>If</font>
<font color=#000099>End</font> <font color=#000099>If</font>
<font color=#000099>End</font> <font color=#000099>With</font>
<font color=#000099>End</font> <font color=#000099>Sub</font></code> Cu
Dieter |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
sevAniGif (VB/VBA) 
Anzeigen von animierten GIF-Dateien
Ab sofort lassen sich auch unter VB6 und VBA (Access ab Version 2000) animierte GIF-Grafiken anzeigen und abspielen, die entweder lokal auf dem System oder auf einem Webserver gespeichert sind. Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) TOP Entwickler-Paket 
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1866.50 EUR...
Jetzt nur 979,00 EURWeitere Infos
|
|
|
Copyright ©2000-2025 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|