VB Code:
Private Declare Function SetWindowPos Lib "user32.dll" ( _
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
Private Const HWND_NOTOPMOST As Long = -2
Private Const HWND_TOPMOST As Long = -1
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOSIZE As Long = &H1
Private Sub TopMost(Optional blnTopMost As Boolean = True)
Dim hwndAfter As Long
If blnTopMost Then
hwndAfter = HWND_TOPMOST
Else
hwndAfter = HWND_NOTOPMOST
End If
Call SetWindowPos(Me.hwnd, hwndAfter, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Simply call the TopMost sub. You can optionally pass True to set it topmost or False to not set it topmost (restore it). Default value is True.