Hi,
How can I make a form stay always on top ? (In similiar to Windows Clock utility).
Yaron.
Printable View
Hi,
How can I make a form stay always on top ? (In similiar to Windows Clock utility).
Yaron.
put this in a module..
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
'constants for SetWindowPos API
private Const SWP_NOMOVE = 2
private Const SWP_NOSIZE = 1
private Const HWND_TOPMOST = -1
private Const HWND_NOTOPMOST = -2
public Sub SetOnTop(byval hwnd as Long, byval bSetOnTop as Boolean)
Dim lR as Long
If bSetOnTop then
lR = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _
SWP_NOSIZE)
else
lR = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _
SWP_NOSIZE)
End If
End Sub
Then in your form load event..
private Sub Form_Load()
'keep form on top of everything
SetOnTop me.hwnd, true
End Sub