UsPBarStBar




'Module Declares

Public Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Public Declare Function SendMessageAny Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal msg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Const WM_USER = &H400
Public Const SB_GETRECT = (WM_USER + 10)
'_________________________________________________________


Private Sub ShowProgress(Mode As Boolean)
Dim rc As RECT
StatusBar1.Panels("keyProgress").Visible = Mode

If Mode Then
'2 => Panel index (0 based)

SendMessageAny StatusBar1.hwnd, SB_GETRECT, 2, rc

With rc
.Top = .Top * Screen.TwipsPerPixelY
.Left = .Left * Screen.TwipsPerPixelX
.Bottom = .Bottom * Screen.TwipsPerPixelY - .Top
.Right = .Right * Screen.TwipsPerPixelX - .Left
End With

With ProgressBar1
SetParent .hwnd, StatusBar1.hwnd
.Move rc.Left, rc.Top, rc.Right, rc.Bottom
.Visible = True
.Value = 0
End With
Else
SetParent ProgressBar1.hwnd, Me.hwnd
ProgressBar1.Visible = False
End If

End Sub

1. Create statusbar With few panels
2. Create invisible progressbar
3. Add test button which calls ShowProgress Sub shown below










( uspbarstbar.html )- by Paolo Puglisi - Modifica del 17/12/2023