This code will keep your form always on top. To test this code
do the following.
Start a new project and add another form to your project.
Add a commmand button to Form1 and add the following code
Private Sub Command1_Click()
Form2.Show
End Sub
Cut and past the rest of the code under Form2. When you run
the program click on the command button. Once Form2 loads it
will always stay on top of all the other forms. To put the
form back to normal just double click on Form2.
============================================================
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, y, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
'// Resets the windows position in the ZOrder
Private Sub MakeNormal(lngHwnd As Long)
SetWindowPos lngHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
'// Places the window at the top of the ZOrder
'// and keeps it there
Private Sub MakeTopMost(lngHwnd As Long)
Dim results As String
results = SetWindowPos(lngHwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS)
End Sub
Private Sub Form_DblClick()
MakeNormal Me.hwnd
End Sub
Private Sub Form_Load()
MakeTopMost Me.hwnd
End Sub