by [email protected] (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sun 26th November 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
form stay on top of other forms
API Declarations
' This statement should be placed in the module.
Declare Function SetWindowPos Lib "user32" Alias_ "SetWindowPos" (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
' Set some constant values (from WIN32API.TXT).
Const conHwndTopmost = -1
Const conHwndNoTopmost = -2
Const conSwpNoActivate = &H10
Const conSwpShowWindow = &H40
Private Sub mnuTopmost_Click ()
' Add or remove the check mark from the menu.
mnuTopmost.Checked = Not mnuTopmost.Checked
If mnuTopmost.Checked Then
' Turn on the TopMost attribute.
SetWindowPos hWnd, conHwndTopmost, 0, 0, 0, 0,_ conSwpNoActivate Or conSwpShowWindow
Else
' Turn off the TopMost attribute.
SetWindowPos hWnd, conHwndNoTopmost, 0, 0, 0,_ 0, conSwpNoActivate Or conSwpShowWindow
End If
End Sub