
Help: How to create a VB application that is always-on-top of all other windows?
Jingbo,
To force the form to say on top, try the following code:
Option Explicit
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 HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Sub Form_Activate()
Dim lRet&
lRet& = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE)
End Sub
To stop it being on top, send a SetWindowPos with an argument of
HWND_NOTOPMOST.
HTH
Peter
Quote:
>Hello,
>This VB application main window has higher priority than others. Even you
>focus on other opened windows, this VB application is still on the top and
>keep running. I have seen some windows applications like this, I would like
>to know if this can be done in VB, and how?
>a T d H v A a N n K c S e
>(Thanks in advance)
>Jingbo Zheng