VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



StayOnTop

by Found on the World Wide Web (15 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Keep a form always on top (topmost floating form) in windows 95.
Albetski, Allan"

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 StayOnTop

Public Sub StayOnTop(frmForm As Form, fOnTop As Boolean)
 
 Const HWND_TOPMOST = -1
 Const HWND_NOTOPMOST = -2
 
 Dim lState As Long
 Dim iLeft As Integer, iTop As Integer, iWidth As Integer, iHeight As Integer
  
 With frmForm
  iLeft = .Left / Screen.TwipsPerPixelX
  iTop = .Top / Screen.TwipsPerPixelY
  iWidth = .Width / Screen.TwipsPerPixelX
  iHeight = .Height / Screen.TwipsPerPixelY
 End With
 
 If fOnTop Then
  lState = HWND_TOPMOST
 Else
  lState = HWND_NOTOPMOST
 End If
 Call SetWindowPos(frmForm.hWnd, lState, iLeft, iTop, iWidth, iHeight,0)
End Sub

Download this snippet    Add to My Saved Code

StayOnTop Comments

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

Post your comment

Subject:
Message:
0/1000 characters