Servus,
warum nimmst Du nicht eine "eigene" Progressbar, verbiegst den "Owner" ein wenig und blendest sie dann irgendwo am Desktoprand über allen anderen Fenstern ein?
Folgenden Code einfach in ein Form-Modul kopieren und auf der Form folgende Controls platzieren:
- Command1
- Command2
- Timer1
- Progressbar1
(sämtliche Eigenschaften der Controls werden im Load-Event der Form gesetzt)Option Explicit
Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long
Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As _
Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Const HWND_TOPMOST As Long = -1
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TOOLWINDOW = &H80&
Private Sub Command1_Click()
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
ProgressBar1.Value = ProgressBar1.Min
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
ProgressBar1.Visible = False
End Sub
Private Sub Form_Load()
Dim R As RECT
' Größe des Desktop's ermitteln
GetWindowRect GetDesktopWindow, R
With ProgressBar1
' Ansicht der Progressbar festlegen
.BorderStyle = ccFixedSingle
.Appearance = ccFlat
.Scrolling = ccScrollingStandard
' Wertebereich der Progressbar festlegen
.Min = 1
.Max = 100
.Value = .Min
' >>>>> die Reihenfolge der nächsten 4 Code-Zeilen bitte beibehalten
' Eigentümer der Progressbar auf "nirgendwer" setzen
' - Muss unbedingt vor dem Unload der Form wieder zurückgesetzt werden,
' sonst droht ein VB- bzw. Programm-Absturz
SetParent .hwnd, 0
' Position der Proressbar setzen und im Vordergrund halten (u.a. 10 Pixel
' hoch)
SetWindowPos .hwnd, HWND_TOPMOST, R.Left, R.Bottom - 10, R.Right, 10, 0
'Progressbar ausblenden
.Visible = False
SetWindowLong .hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW
' <<<<< bis hier hin bitte die Reihenfolge nicht ändern
End With
With Timer1
.Enabled = False
.Interval = 50
End With
With Command1
.Caption = "Start!"
.Left = 240
.Top = 240
.Width = 1200
.Height = 360
.Enabled = True
End With
With Command2
.Caption = "Stop!"
.Left = Command1.Left + Command1.Width
.Top = 240
.Width = 1200
.Height = 360
.Enabled = False
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Eigentümer der Progressbar wiederherstellen
' (damits kein Absturz gibt)
SetParent ProgressBar1.hwnd, hwnd
End Sub
Private Sub Timer1_Timer()
With ProgressBar1
If .Value < .Max Then
.Value = .Value + 1
' >>>>> die Reihenfolge der nächsten 2 Code-Zeilen bitte beibehalten
' Wichtig! im Vordergrund halten
SetWindowPos .hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
' Wichtig! sichtbar halten
.Visible = True
' <<<<< bis hier hin bitte die Reihenfolge nicht ändern
Else
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
.Visible = False
End If
End With
End Sub Viel Spass,
R@lf |