VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Keep a form on top

by omidles (4 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 11th November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Keep a form on top

API Declarations


Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Private Declare Function SetWindowPos Lib "user32" (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 Declare Function GetActiveWindow Lib "user32" () As Long

Public Sub MakeWindowAlwaysTop(hwnd As Long)
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
End Sub

Public Sub MakeWindowNotTop(hwnd As Long)
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
End Sub

Rate Keep a form on top



Timer1.Interval = 1 
End Sub 

Private Sub Timer1_Timer() 
MakeWindowAlwaysTop Me.hwnd 
End Sub

Download this snippet    Add to My Saved Code

Keep a form on top Comments

No comments have been posted about Keep a form on top. Why not be the first to post a comment about Keep a form on top.

Post your comment

Subject:
Message:
0/1000 characters