Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 8th, 2003 03:55 AM Post subject: Form Always on Top Module |
|
|
Hi!
Ever wondered how to put your form always on top of other windows ? This piece of code just let's you do that.
Put the code in a module:
[vb:1:c02619109e]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
Public Sub AlwaysOnTop(F As Form, Enabled As Boolean)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
If Enabled Then
SetWindowPos F.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos F.hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub[/vb:1:c02619109e]
Usage:
[vb:1:c02619109e]AlwaysOnTop Me, True[/vb:1:c02619109e] |
|