Search Tools Links Login

Place a progress bar in a status bar panel


Place a status bar and a progress bar on a form and make the progress bar invisible.

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
      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

About this post

Posted: 2020-08-30
By: vb6boy
Viewed: 223 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.