Always on top 
Author Message
 Always on top

I need a quick and simple way to make a form always be on
top.


Thu, 16 Sep 2004 08:31:53 GMT  
 Always on top
The simplest (and as far as I know only) way to do this is calling the
win32-API. The following code example would create a form that's always on
top from the moment it is loaded until someone clicks Button1:

Option Explicit
Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

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 Command1_Click()
    SetAOT False
End Sub

Private Sub Form_Load()
    SetAOT True
End Sub

Private Sub SetAOT(Switch As Boolean)
    If Switch Then
        SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE
    Else
        SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE
    End If
End Sub

Carsten Duellmann



Quote:
> I need a quick and simple way to make a form always be on
> top.



Thu, 16 Sep 2004 09:22:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Always on top (ALWAYS)

2. Make a form always on top - always

3. Make a window always on top (of every window..always)

4. Keeping a Form Always On Top

5. VBA Form Always On Top

6. MsgBox Always On-Top

7. Always on TOP Property

8. Always on top application

9. Windows ALWAYS on top ...

10. Always on top

11. Form always on top

12. Form always on top

 

 
Powered by phpBB® Forum Software