VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6.

by Chris Eastwood (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 22nd February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6.

API Declarations


Module Declares for the StatProgressBar example

Chris Eastwood Feb. 1999

http://www.codeguru.com/vb



API Declarations

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


API Types

RECT is used to get the size of the panel were inserting into

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


API Messages

Public Const WM_USER As Long = &H400
Public Const SB_GETRECT As Long = (WM_USER + 10)


Rate How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6.




    Dim tRC As RECT
    
    If bShowProgressBar Then
'
' Get the size of the Panel (2) Rectangle from the status bar
' remember that Indexes in the API are always 0 based (well,
' nearly always) - therefore Panel(2) = Panel(1) to the api
'
'
        SendMessageAny StatusBar1.hwnd, SB_GETRECT, 1, tRC
'
' and convert it to twips....
'
        With tRC
            .Top = (.Top * Screen.TwipsPerPixelY)
            .Left = (.Left * Screen.TwipsPerPixelX)
            .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
            .Right = (.Right * Screen.TwipsPerPixelX) - .Left
        End With
'
' Now Reparent the ProgressBar to the statusbar
'
        With ProgressBar1
            SetParent .hwnd, StatusBar1.hwnd
            .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
            .Visible = True
            .Value = 0
        End With
        
    Else
'
' Reparent the progress bar back to the form and hide it
'
        SetParent ProgressBar1.hwnd, Me.hwnd
        ProgressBar1.Visible = False
    End If
    
End Sub


See http://www.codeguru.com/vb/articles/1639.shtml for a full sample application


Download this snippet    Add to My Saved Code

How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6. Comments

No comments have been posted about How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6.. Why not be the first to post a comment about How to place a Progress Bar in A Status Bar Panel (VB5) - should work with VB4(32 bit) and VB6..

Post your comment

Subject:
Message:
0/1000 characters