Results 1 to 5 of 5

Thread: Using ProgressBar IN a StatusBar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    Can anyone tell me how can I place ProgressBar control in a StatusBar and use it there, like in IE.

    Thanks
    Thanks

    Tomexx.

  2. #2
    Guest
    Try this:

    Code:
    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 we're 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)
    
    
    Private Sub ShowProgressInStatusBar(ByVal bShowProgressBar As Boolean)
    
        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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Thanks Matthew,
    I see you're using APIs. Don't have much experience with Windows APIs. Do I still have to place the progressBar control on the form? If so where?
    I thought I could just place the ProgressBar control & somehow 'attach' it to the StatusBar. Was I wrong?

    Thanks again.
    Thanks

    Tomexx.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Anyone else?
    Thanks

    Tomexx.

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Code:
    Private Sub Form_Resize()
    ProgressBar1.Move StatusBar1.Width - ProgressBar1.Width - 200, StatusBar1.Top
    End Sub
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width