Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving the progress bar to the middle of the screen

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
Hi is it possible to remove the progress bar from the bottom left, (its default position) and insert it in a form or move it somewhere else?
thanks
 
I don't think the progress bar can be moved. However, it is simple to create your own for display on a form. Either use an ActiveX control (such as contained within Microsoft Windows Common Controls 6.0 as supplied with VB6), or better still make your own out of two labels.

I create two labels, one of which is the 'outer', the other the 'inner'. I set the outer label to have a border, but with transparent fill so the 'inner' label can be seen through it. This is the label that displays the progress percentage text. The inner label is the actual progress bar, and I set the width to a proportion of the outer label width according to how far we have progressed.

Private Sub ShowProgress(RCount As Long, TotalCount As Long)
'RCount is how many we have done so far
'TotalCount is how many for the whole job
Dim NewWidth As Single
If TotalCount = 0 Then 'Quick way to reset the bar, by passing total of zero
NewWidth = 0
lblProgressOuter.Caption = ""
Else
NewWidth = lblProgressOuter.Width * (RCount / TotalCount)
lblProgressOuter.Caption = CLng((RCount / TotalCount) * 100) & "%"
End If
lblProgressInner.Width = NewWidth
End Sub

You can change the two labels' Visible properties when you want to 'switch' them off and on again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top