Results 1 to 3 of 3

Thread: progressbar put in statusbar

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    progressbar put in statusbar

    im trying to put my progressbar on statusbar..

    i did like this

    VB Code:
    1. ProgressBar1.Left = StatusBar1.Panels(1).Left + 40
    2. ProgressBar1.Top = StatusBar1.Top + 60
    3. ProgressBar1.Width = StatusBar1.Width - StatusBar1.Panels(1).Left - 800
    4. ProgressBar1.Height = StatusBar1.Height - 90

    my problem is i cant put a percentage text on the center of statusbar, how i can put a percentage text on the front of progressbar?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: progressbar put in statusbar

    The progressbar itself doesn't have a caption property and since a Label is a windowless control you can't put one infront of the progressbar either. The two solutions I can think of is to either subclass the progressbar and check for the WM_PAINT message and then do the drawing of the progress yourself including a text caption. However that is somewhat involved and it would be a lot easier to simply replace the progressbar with a picture box on which you draw the progress.
    VB Code:
    1. Public Sub DrawProgress( _
    2.  pic As PictureBox, _
    3.  ByVal sngPercent As Single, _
    4.  Optional ByVal nColor As Long = vbBlue)
    5.     Dim sText As String
    6.     If sngPercent >= 1 Then
    7.         sngPercent = sngPercent / 100
    8.     End If
    9.     pic.Cls
    10.     pic.Line (0, 0)-(pic.ScaleWidth * sngPercent, pic.ScaleHeight), nColor, BF
    11.     sText = CInt(sngPercent * 100) & "%"
    12.     pic.CurrentX = (pic.ScaleWidth - pic.TextWidth(sText)) \ 2
    13.     pic.CurrentY = (pic.ScaleHeight - pic.TextHeight(sText)) \ 2
    14.     pic.Print sText
    15. End Sub
    You can use the above Sub to turn any picture box into a progressbar. Simply pass the picturebox and the percentage as arguments. You may optionally also pass the color the progressbar should have as an argument. The text will be colored using the ForeColor of the PictureBox.

  3. #3
    Lively Member
    Join Date
    Apr 2004
    Posts
    113

    Re: progressbar put in statusbar

    There is an excellent Progress Bar class here:

    http://www.vbaccelerator.com/home/VB...ss/article.asp

    This will let you have a caption on the progress bar itself, as well as control the colors etc...

    If you don't want a class you can use the control instead:

    http://www.vbaccelerator.com/home/VB...ol/article.asp

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