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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

progress bar in status bar

Status
Not open for further replies.

Fosters

Programmer
Mar 6, 2001
16
0
0
GB
I'm using the following code to position a progress bar within panel 2 of a status bar. Calling the sub on form_resize is fine, but when maximising the form the progress bar stays put. How do I detect the maximise?

rgds
Mike

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As _
Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SendMessageAny 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)


Private Sub ShowProgressInStatusBar(ByVal bShowProgressBar As Boolean)

Dim tRC As RECT

If bShowProgressBar Then
SendMessageAny SB.hwnd, SB_GETRECT, 1, tRC

With tRC
.Top = (.Top * Screen.TwipsPerPixelY)
.Left = (.Left * Screen.TwipsPerPixelX)
.Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
.Right = (.Right * Screen.TwipsPerPixelX) - .Left
End With

With PB
SetParent .hwnd, SB.hwnd
.Move tRC.Left + 30, tRC.Top + 30, tRC.Right - 60, tRC.Bottom - 60
.Visible = True
.Value = 0
End With

Else
SetParent PB.hwnd, Me.hwnd
PB.Visible = False
End If

End Sub
 
When a form is maximized, a Form_Resize event is fired. You can reposition your progress bar in that event.

Good luck!

-Mike Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top