VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Always On Top

by Adam Jacob Muller (3 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (12 Votes)

Keeps Your Form On Top
This Is Really Kewl Because You Can Just Use A false attribuite to set it as not on top instead of using 2 functions

API Declarations
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

Rate Always On Top

Public Sub AlwaysOnTop(myfrm As Form, SetOnTop As Boolean)
  If SetOnTop Then
   lFlag = HWND_TOPMOST
  Else
   lFlag = HWND_NOTOPMOST
  End If
  SetWindowPos myfrm.hwnd, lFlag, _
  myfrm.Left / Screen.TwipsPerPixelX, _
  myfrm.Top / Screen.TwipsPerPixelY, _
  myfrm.Width / Screen.TwipsPerPixelX, _
  myfrm.Height / Screen.TwipsPerPixelY, _
  SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub
'Well, if your for example in a form called 'Form1' then you'd simply type:
AlwaysOnTop Form1, True

Download this snippet    Add to My Saved Code

Always On Top Comments

No comments have been posted about Always On Top. Why not be the first to post a comment about Always On Top.

Post your comment

Subject:
Message:
0/1000 characters