StayOnTop




Type Rect
Height As Integer
Left As Integer
Top As Integer
Width As Integer
End Type

Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Global Const SWP_NOACTIVATE = &H10
Global Const SWP_SHOWWINDOW = &H40
Declare Sub SetWindowPos Lib

Public Sub StayOnTop(hWnd As Long, Size As Rect)
SetWindowPos hWnd, HWND_TOPMOST, Size.Left / 15, _
Size.Top / 15, Size.Width / 15, _
Size.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub

Public Sub NotStayOnTop(hWnd As Long, Size As Rect)
SetWindowPos hWnd, HWND_NOTOPMOST, Size.Left / 15, _
Size.Top / 15, Size.Width / 15, _
Size.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub

'on declarations

Dim Size as Rect
'Call Subs

Call StayOnTop (hWnd, Size)
call NotStayOnTop (hWnd, Size)
'For free distribution!

Sub Resized (form)
size.width = form.width
size.height = form.height
size.top = form.top
size.left = form.left
End Sub











( stayontop.html )- by Paolo Puglisi - Modifica del 17/12/2023