Public Sub StayOnTop(frmForm
As Form, fOnTop As Boolean, bottom
As Boolean)
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const HWND_BOTTOM = 1
Const HWND_TOP = 0
Dim lState As Long,
iLeft As Integer, iTop As
Integer, iWidth As Integer, iHeight
As Integer
With frmForm
iLeft = .Left / Screen.TwipsPerPixelX
iTop = .Top / Screen.TwipsPerPixelY
iWidth = .Width / Screen.TwipsPerPixelX
iHeight = .Height / Screen.TwipsPerPixelY
End With
If bottom = False Then
If fOnTop Then
lState = HWND_TOPMOST
Else
lState = HWND_NOTOPMOST
End If
Else
lState = HWND_BOTTOM
End If
Call SetWindowPos(frmForm.hwnd, lState, iLeft, iTop,
iWidth, iHeight, 0)
End Sub