Results 1 to 4 of 4

Thread: Progress Bar as a Status Bar Panel?

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Is there a way to make a panel of the status bar control act like a progress bar? I see examples of this in many apps, including IE right now during transitions from page to page on this site. Thanks for your help.
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    It's easier just to add a Statusbar panel, and overlay a standard progress bar on top of it.

    If you're feeling really clever you could even dynamically adjust the size of the progress bar to fit the panel at runtime. The end user would be none the wiser.

    I'm not aware of any way you can create a progress bar WITHIN a StatusBar. But like you said - Explorer does it so it must be possible.

    You might have to dive into the realms of WinAPI to achieve what you want...

    Visual Basic 6 Enterprise Edition + SP4

  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Code:
    Option Explicit
    
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Const WM_USER As Long = &H400
    Private Const SB_GETRECT As Long = (WM_USER + 10)
    Public Sub ShowProgressInStatus(pProgress As ProgressBar, pStatus As StatusBar, pPanelIndex As Integer)
        Dim tRC As RECT
        pProgress.Appearance = ccFlat
        'Get the size of the given panel
        SendMessage pStatus.hwnd, SB_GETRECT, pPanelIndex, tRC
        'Convert to Twips
        With tRC
            .Top = (.Top * Screen.TwipsPerPixelY) + 30
            .Left = (.Left * Screen.TwipsPerPixelX) + 30
            .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top - 30
            .Right = (.Right * Screen.TwipsPerPixelX) - .Left - 30
        End With
        'Reparent the ProgressBar to the statusbar
        With pProgress
            SetParent .hwnd, pStatus.hwnd
            .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
            .Visible = True
            .Value = 0
        End With
    End Sub
    
    
    Private Sub Command1_Click()
        ShowProgressInStatus ProgressBar1, StatusBar1, 0
        ProgressBar1.Value = 50
    
    End Sub

  4. #4

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Thumbs up

    WOW! Thanks a lot, Frans! I tried it and it works great!!
    "It's cold gin time again ..."

    Check out my website here.

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