Results 1 to 2 of 2

Thread: easy one - always on top

  1. #1

    Thread Starter
    Addicted Member Jakys's Avatar
    Join Date
    Dec 1999
    Location
    Norway
    Posts
    180

    Question

    How do I get a form to be "always on top". I know i have seen this code many times, but I just can't remember where!

    Tnx in advance

  2. #2
    Guest
    Use the SetWindowPos api function.

    Code:
    Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
      (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
    
    Const SWP_NOMOVE = 2 
    Const SWP_NOSIZE = 1 
    Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE 
    Const HWND_TOPMOST = -1 
    Const HWND_NOTOPMOST = -2
    
    
    Private Sub Form_Load()
    SetWindowPos Me.hWnd, HWND_TOPMOST, _
    0, 0, 0, 0, FLAGS
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width