Attribute VB_Name = "AlwaysOnTop"
Private 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 Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

Public Sub InAlwaysOnTop(ByVal NForm As Object)
' Fenêtre toujours au premier plan
SetWindowPos NForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, 3
End Sub

Public Sub NotAlwaysOnTop(ByVal NForm As Object)
' Annule Fenêtre toujours au premier plan
SetWindowPos NForm.hwnd, HWND_NOTOPMOST, X%, Y%, W%, H%, 3
End Sub

Public Sub AlwaysOnTopHwnd(ByVal NHwnd As Long)
    SetWindowPos NHwnd, HWND_TOPMOST, 0, 0, 0, 0, 3
End Sub

Public Sub NotAlwaysOnTopHwnd(ByVal NHwnd As Long)
    Dim X%, Y%, W%, H%
    SetWindowPos NHwnd, HWND_NOTOPMOST, X%, Y%, W%, H%, 3
End Sub
