Apr 7, 2001
MoveProgressBarIntoPanel - Move a ProgressBar inside a StatusBar's panel
' Move and resize a ProgressBar control so that it fits inside
' a StatusBar's Panel.
' The last argument is the panel index (one-based).
Sub MoveProgressBarIntoPanel(pb As ProgressBar, sb As StatusBar, _
pnlIndex As Integer)
Dim deltaY As Single, pnl As Panel, y As Single
' account for two pixels around each panel
deltaY = pb.Parent.ScaleY(2, vbPixels, vbTwips)
Set pnl = sb.Panels(pnlIndex)
pnl.Bevel = sbrNoBevel
' It is necessary to evaluate the Y coordinate in this way because
' if this routine is invoked from Form_Resize you can't rely on
' the StatusBar's or Panel's Top property, which still has to be updated.
y = pb.Parent.ScaleHeight - sb.Height
' Move the progress bar in position, and in front of the status bar.
pb.Move pnl.Left, y + deltaY, pnl.Width, sb.Height - deltaY
pb.Visible = True