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
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