Programming » Visual Basic 6 » Visual Basic 6 Code » Forms » ");?>
Puts the form above all other windows and makes it stay there.
Public Declare Function SetWindowPos Lib "user32" _
        (ByVal hWnd As Long, _
        ByVal hWndInsertAfter As Long, _
        ByVal X As LongByVal Y As Long, _
        ByVal cx As LongByVal cy As Long, _
        ByVal wFlags As LongAs Long
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const SWP_WNDFLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2

Public Sub SetTopmost(frm As Form, bTopmost As Boolean)
    Dim i As Long
    If bTopmost = True Then
        i = SetWindowPos(frm.hWnd, HWND_TOPMOST, _
                0, 0, 0, 0, SWP_WNDFLAGS)
    Else
        i = SetWindowPos(frm.hWnd, HWND_NOTOPMOST, _
                0, 0, 0, 0, SWP_WNDFLAGS)
    End If
End Sub