Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fortschrittsanzeige bzw. Prozentbalken in Statusleiste???

353 views
Skip to first unread message

Alexander Magdanz

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
Hallo,
wie kann ich es unter Excel realisieren, daß ich in der Statusleiste
eine Fortschrittsanzeige bzw. einen Prozentbalken anzeigen kann???
Danke im Voraus.

Alexander Magdanz

Marcus Schmitt

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
Sub Fortschritt()
Max = 100000
For x = 1 To Max
Application.StatusBar = Format((100 / Max) * x, "0") & "%"
Next x
Application.StatusBar = False
End Sub


Gruß
Marcus
http://www.schmittis-page.de


"Alexander Magdanz" <amag...@computerschule-am.de> schrieb im Newsbeitrag
news:e2Gkhdyc$GA....@cppssbbsa02.microsoft.com...

Marcel Kränzle

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
Hallo Alexander,

ich hatte das gleiche Problem und Frank Ahrend-Theilen hat mir einen
Beitrag
von Michael Schwimmer zugemailt.
Here it is:

-------------------------------schnipp----------------------------------------
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal szClass$, _
ByVal szTitle$) As Long
Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" _
Alias "GetClassNameA" (ByVal hwnd As Long, _
ByVal lpClassName As String, ByVal nmaxCount _
As Long) As Long
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
(ByVal crColor As Long) As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function FillRect& Lib "user32" _
(ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long)
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Private Const SM_CXSCREEN = 0
Private Const PS_SOLID = 0
Private Const GW_CHILD As Integer = 5
Private Const GW_HWNDFIRST As Integer = 0
Private Const GW_HWNDNEXT As Integer = 2
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Sub Fortschritt(ByVal BreiteProzent)
Static hPinsel&
Dim hFenster&, lngDcFenster&, strKlassenname$
Dim lngRück&, udtFenstergröße As RECT
Dim GesamtBreite, lngBreite&, lngGesamtHöhe&
Dim lngFortschrittsleiste&, lngFarbe&
'Hier kann die Farbe festgelegt werden
lngFarbe = RGB(0, 255, 0)
strKlassenname = String(256, 0)
'*****Fenster Statusleiste finden*****
hFenster = FindWindow("XLMAIN", Application.Caption)
hFenster = GetWindow(hFenster, GW_CHILD)
lngRück = GetClassName(hFenster, strKlassenname, 255)
strKlassenname = Left$(strKlassenname, lngRück)
If strKlassenname <> "EXCEL4" Then Exit Sub
'*****Größe Festlegen*****
lngRück = GetWindowRect(hFenster, udtFenstergröße)
GesamtBreite = udtFenstergröße.Right - udtFenstergröße.Left
lngGesamtHöhe = udtFenstergröße.Bottom - udtFenstergröße.Top
'Hier eventuell etwas experimentieren.
'Dient zur Anpassung, wenn das Excel-Fenster nicht maximale Größe hat
If GesamtBreite < GetSystemMetrics(SM_CXSCREEN) Then
lngFortschrittsleiste = CLng((GetSystemMetrics(SM_CXSCREEN) _
/ 1000) * 488)
Else
lngFortschrittsleiste = CLng((GetSystemMetrics(SM_CXSCREEN) _
/ 1000) * 465)
End If
If lngFortschrittsleiste > GesamtBreite Then Exit Sub
If BreiteProzent > 100 Then BreiteProzent = 100
If BreiteProzent < 0 Then BreiteProzent = 0
GesamtBreite = GesamtBreite - lngFortschrittsleiste
lngBreite = CLng((GesamtBreite / 1000) * BreiteProzent * 10)
udtFenstergröße.Left = 0
udtFenstergröße.Top = 0
udtFenstergröße.Right = lngBreite
udtFenstergröße.Bottom = lngGesamtHöhe
'*****Pinsel erzeugen*****
If hPinsel = 0 Then
hPinsel = CreateSolidBrush(lngFarbe)
End If
'*****Fenster DC ausleihen*****
lngDcFenster = GetDC(hFenster)
'*****Malen in DC*****
lngRück = FillRect(lngDcFenster, udtFenstergröße, hPinsel)
'*****DC zurückgeben*****
lngRück = ReleaseDC(hFenster, lngDcFenster)
End Sub
-------------------------------schnapp----------------------------------------


Ciao
Marcel

Peter Ostermann

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to Alexander Magdanz

Hallo Alexander,

mit dieser fertigen "ProgressBar" hast Du die optisch bestse Lösung.
Teile bitte mit wie Du damit klar kommst.

Gruß
Peter

Steuerelement: Fortschrittsanzeige

Öffnen Sie im VBA-Editor durch Anklicken des Werkzeugsymbols in der
Symbolleiste die Werk-zeug-sammlung. Klicken Sie dort mit der rechten
Maustaste, um das Kontextmenü zu öffnen. Wählen Sie den Befehl "Weitere
Steuerelemente". Aus der sich dann öffnenden Auswahlliste wählen Sie die
Optionen

? Microsoft ProgressBar Control, version 5 (SP2) (Service Pack 2 wird
vorausgesetzt)
? Microsoft ProgressBar Control, version 6

Der folgende Hiilfetext bezieht sich auf die Version 6.0


The ProgressBar control shows the progress of a lengthy operation by
filling a rectangle with chunks from left to right.

Syntax

ProgressBar

Remarks

· The ProgressBar control monitors an operation's progress toward
completion.

A ProgressBar control has a range and a current position. The range
represents the entire duration of the operation. The current position
represents the progress the application has made toward completing the
operation. The Max and Min properties set the limits of the range. The
Value property specifies the current position within that range. Because
chunks are used to fill in the control, the amount filled in only
approximates the Value property's current setting. Based on the
control's size, the Value property determines when to display the next
chunk.

The ProgressBar control's Height and Width properties determine the
number and size of the chunks that fill the control. The more chunks,
the more accurately the control portrays an operation's progress. To
increase the number of chunks displayed, decrease the control's Height
or increase its Width. The BorderStyle property setting also affects the
number and size of the chunks. To accommodate a border, the chunk size
becomes smaller.

You can use the Align property with the ProgressBar control to
automatically position it at the top or bottom of the form.

Tip To shrink the chunk size until the progress increments most
closely match actual progress values, make the ProgressBar control at
least 12 times wider than its height.

How to use the ProgressBar control
The following example shows how to use the ProgressBar control, named
ProgressBar1, to show the progress of a lengthy operation of a large
array. Put a CommandButton control and a ProgressBar control on a form.
The Align property in the sample code positions the ProgressBar control
along the bottom of the form. The ProgressBar control displays no text.

Private Sub Command1_Click()
Dim Counter As Integer
Dim Workarea(250) As String
ProgressBar1.Min = LBound(Workarea)
ProgressBar1.Max = UBound(Workarea)
ProgressBar1.Visible = True

'Set the Progress's Value to Min.
ProgressBar1.Value = ProgressBar1.Min

'Loop through the array.
For Counter = LBound(Workarea) To UBound(Workarea)
'Set initial values for each item in the array.
Workarea(Counter) = "Initial value" & Counter
ProgressBar1.Value = Counter

Next Counter
ProgressBar1.Visible = False
ProgressBar1.Value = ProgressBar1.Min
End Sub

Private Sub Form_Load()
ProgressBar1.Align = vbAlignBottom
ProgressBar1.Visible = False
Command1.Caption = "Initialize array"
End Sub

Distribution Note
The ProgressBar control is part of a group of ActiveX controls that are
found in the COMCTL32.OCX file. To use the ProgressBar control in your
application, you must add the COMCTL32.OCX file to the project. When
distributing your application, install the COMCTL32.OCX file in the
user's Microsoft Windows System or System32 directory. For more
information on how to add an ActiveX control to a project, see the
Programmer's Guide.


Alexander Magdanz schrieb:

> Hallo,
> wie kann ich es unter Excel realisieren, daß ich in der Statusleiste
> eine Fortschrittsanzeige bzw. einen Prozentbalken anzeigen kann???
> Danke im Voraus.
>
> Alexander Magdanz

--
http://home.nordwest.net/Peter.Ostermann/

0 new messages