by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Set your Window on top of all forms using SetWindowPos API
API Declarations
Const HWND_BOTTOM = 1 ' Put the window at the bottom of the Z-order.
Const HWND_NOTOPMOST = -2 ' Put the window below all topmost windows and above all non-topmost windows.
Const HWND_TOP = 0 'Put the window at the top of the Z-order.
Const HWND_TOPMOST = -1 'Make the window topmost of all other windows.
Const SWP_FRAMECHANGED = &H20 'The frame changed: send WM_NCCALCSIZE
Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Const SWP_HIDEWINDOW = &H80
Const SWP_NOACTIVATE = &H10
Const SWP_NOMOVE = &H2
Const SWP_NOCOPYBITS = &H100
Const SWP_NOOWNERZORDER = &H200
Const SWP_NOREDRAW = &H8
Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_SHOWWINDOW = &H40
Dim rval As Long
'Bring to normal condition
rval = SetWindowPos(Form1.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE)
End Sub
Private Sub Form_Load()
'Set window on top of all
rval = SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE)
End Sub
'Visit my Homepage at
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]