|
| |

Visual-Basic Einsteiger| Re: Grafische Darstellung von Freiem Speicherplatz | |  | Autor: Dieter (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 |  |
 | 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 |
  |
|
sevISDN 1.0 
Überwachung aller eingehender Anrufe!
Die DLL erkennt alle über die CAPI-Schnittstelle eingehenden Anrufe und teilt Ihnen sogar mit, aus welchem Ortsbereich der Anruf stammt. Weitere Highlights: Online-Rufident, Erkennung der Anrufbehandlung u.v.m. Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) Neu! sevEingabe 3.0 
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere 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
|
|