Results 1 to 6 of 6

Thread: form to top

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115

    form to top

    how do I make a form that stays allways on top?

    VIP
    ICQ :137108715
    MSN Messenger : [email protected]

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 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
    2.  
    3. Private Const SWP_NOMOVE = 2
    4. Private Const SWP_NOSIZE = 1
    5. Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    6. Private Const HWND_TOPMOST = -1
    7. Private Const HWND_NOTOPMOST = -2
    8.  
    9. Private Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long
    10.   On Error Goto ErrRtn
    11.    If (Topmost) Then
    12.       SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
    13.    Else
    14.       SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
    15.       SetTopMostWindow = False
    16.    End If
    17.    Exit Function
    18. ErrRtn:
    19. MsgBox "Error in SetTopMostWindow " & Err & " " & Error, vbExclamation + vbOKCancel
    20. End Function
    21.  
    22. 'In Form Load Event, put...
    23. 'To Make Always On Top
    24. SetTopMostWindow Me.hwnd, TRUE
    25.  
    26. '(SetTopMostWindow Me.hwnd, FALSE would prevent window from being TopMost)

  3. #3
    New Member
    Join Date
    Dec 2001
    Location
    Colorado
    Posts
    12

    on top form

    I recall seeing this answered @ www.vbcode.com
    To search their data base, simply
    Enter an exact search string "on top"

    You should get several techniques, some using code, some
    using properties

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115
    thanks

    VIP
    ICQ :137108715
    MSN Messenger : [email protected]

  5. #5
    Megatron
    Guest
    To make a Form stay on top:
    VB Code:
    1. 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
    2.  
    3. Private Sub Form_Load()
    4.     SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    5. End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Netherlands
    Posts
    115
    yes, thanks

    VIP
    ICQ :137108715
    MSN Messenger : [email protected]

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