The Easiest way to do this!
This is BEST and FASTEST and SHORTEST way to do this!
Code:
Code:
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Const HWND_TOPMOST = -1
Public Const SWP_SHOWWINDOW = &H40
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
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
Public Sub SetWindowOnTop(frm As Form)
Dim r As RECT
GetWindowRect frm.hwnd, r
SetWindowPos frm.hwnd, HWND_TOPMOST, r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top, SWP_SHOWWINDOW
End Sub
Usage:
SetWindowOnTop Form1 'program code gets Hwnd from form.
---
Thank you, thank you :)