vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
NEU! sevCoolbar 3.0 - Professionelle Toolbars im modernen Design!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Beispiel MediaPlayer - ProgressBar 
Autor: ModeratorDieter (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
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Progressbar149cromec06.03.02 12:42
Beispiel MediaPlayer - ProgressBar418ModeratorDieter06.03.02 13:14
Danke (ot)117cromec06.03.02 19:53
Re: Progressbar122cromec07.03.02 09:03

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

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

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