progressbar put in statusbar
im trying to put my progressbar on statusbar..
i did like this
VB Code:
ProgressBar1.Left = StatusBar1.Panels(1).Left + 40
ProgressBar1.Top = StatusBar1.Top + 60
ProgressBar1.Width = StatusBar1.Width - StatusBar1.Panels(1).Left - 800
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?
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:
Public Sub DrawProgress( _
pic As PictureBox, _
ByVal sngPercent As Single, _
Optional ByVal nColor As Long = vbBlue)
Dim sText As String
If sngPercent >= 1 Then
sngPercent = sngPercent / 100
End If
pic.Cls
pic.Line (0, 0)-(pic.ScaleWidth * sngPercent, pic.ScaleHeight), nColor, BF
sText = CInt(sngPercent * 100) & "%"
pic.CurrentX = (pic.ScaleWidth - pic.TextWidth(sText)) \ 2
pic.CurrentY = (pic.ScaleHeight - pic.TextHeight(sText)) \ 2
pic.Print sText
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.
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