vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Erstellen von dynamischen Kontextmen?s - wann immer Sie sie brauchen!  
 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

Visual-Basic Einsteiger
Re: Grafische Darstellung von Freiem Speicherplatz 
Autor: ModeratorDieter (Moderator)
Datum: 17.04.02 21:06

Hi Boris,

nachfolgend ein Beispiel:
Nimm eine Form und plaziere darauf ein Picture-Control (picProgress), sowie einen Command-Button (Command1).

<code><font color=#000099>Option</font> <font color=#000099>Explicit</font>
 
<font color=green>' zunächst alle benötigten API-Deklarationen</font>
<font color=#000099>Private</font> <font color=#000099>Declare</font> <font _
  color=#000099>Function</font> GetDiskFreeSpaceEx <font _
  color=#000099>Lib</font> "kernel32" _
  <font color=#000099>Alias</font> "GetDiskFreeSpaceExA" (<font _
  color=#000099>ByVal</font> lpDirectoryName <font color=#000099>As</font> _
  <font color=#000099>String</font>, lpFreeBytesAvailableToCaller <font _
  color=#000099>As</font> Currency, _
  lpTotalNumberOfBytes <font color=#000099>As</font> Currency, _
  lpTotalNumberOfFreeBytes <font color=#000099>As</font> Currency) <font _
  color=#000099>As</font> <font color=#000099>Long</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>
 
 
<font color=#000099>Private</font> <font color=#000099>Sub</font> _
  Command1_Click()
  <font color=#000099>Dim</font> BytesAvail <font color=#000099>As</font> _
  Currency
  <font color=#000099>Dim</font> BytesTotal <font color=#000099>As</font> _
  Currency
  <font color=#000099>Dim</font> BytesFree <font color=#000099>As</font> _
  Currency
  <font color=#000099>Dim</font> lResult <font color=#000099>As</font> <font _
  color=#000099>Long</font>
  <font color=#000099>Dim</font> sDrive <font color=#000099>As</font> <font _
  color=#000099>String</font>
  <font color=#000099>Dim</font> intProz <font color=#000099>As</font> <font _
  color=#000099>Long</font>
 
  sDrive = "c:"
  lResult = GetDiskFreeSpaceEx(sDrive, _
    BytesAvail, BytesTotal, BytesFree)
 
  <font color=#000099>If</font> lResult <font color=#000099>Then</font>
    <font color=green>' belegten Speicherplatz anzeigen</font>
    intProz = 100 - Int(BytesAvail / BytesTotal * 100)
    ShowProgress picProgress, intProz, 0, 100
  <font color=#000099>End</font> <font color=#000099>If</font>
<font color=#000099>End</font> <font color=#000099>Sub</font></code>
Cu
Dieter
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Grafische Darstellung von Freiem Speicherplatz148Boris Huemer17.04.02 14:16
Re: Grafische Darstellung von Freiem Speicherplatz220ModeratorDieter17.04.02 21:06
YOU´RE THE BEST! THX27Boris Huemer18.04.02 07:55

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