Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Sub ForceWindowOnTop(hwnd As Long, bTrueFalse As Boolean)
Dim i
If bTrueFalse = True Then
i = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
Else
i = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End If
End Sub
'Then, to call it from a Form:
Private Sub Form_Load()
Call ForceWindowOnTop(Me.hwnd, True)
End Sub
'To turn it off, just use False
Call ForceWindowOnTop(Me.hwnd, True)