how do I make a form that stays allways on top?
VIP
Printable View
how do I make a form that stays allways on top?
VIP
VB Code:
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 Const SWP_NOMOVE = 2 Private Const SWP_NOSIZE = 1 Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long On Error Goto ErrRtn If (Topmost) Then SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) Else SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) SetTopMostWindow = False End If Exit Function ErrRtn: MsgBox "Error in SetTopMostWindow " & Err & " " & Error, vbExclamation + vbOKCancel End Function 'In Form Load Event, put... 'To Make Always On Top SetTopMostWindow Me.hwnd, TRUE '(SetTopMostWindow Me.hwnd, FALSE would prevent window from being TopMost)
I recall seeing this answered @ www.vbcode.com
To search their data base, simply
Enter an exact search string "on top"
You should get several techniques, some using code, some
using properties
thanks
VIP
To make a Form stay on top:
VB Code:
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 Sub Form_Load() SetWindowPos hwnd, -1, 0, 0, 0, 0, 3 End Sub
yes, thanks
VIP