Results 1 to 8 of 8

Thread: How do I make a form always on top of another?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85

    How do I make a form always on top of another?

    The topic pretty much says it all, but I should clarify that I do NOT want the second form to be ontop of EVERYTHING, just the one other form.

    --Anders
    Reality is what you make up when you can't handle your fantasies.

  2. #2
    Addicted Member hamins's Avatar
    Join Date
    Sep 2001
    Posts
    192
    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOACTIVATE = &H10
    Const SWP_SHOWWINDOW = &H40
    Private Declare Sub 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)

    Private Sub Form_Load()
    SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    End Sub
    Knowledge is static .... understanding is Dynamic

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Hmm, no I've tried that. This makes the form ontop of everything. I only want it ontop of the form that opens it.

    --Anders
    Reality is what you make up when you can't handle your fantasies.

  4. #4
    Tygur
    Guest
    VB Code:
    1. 'Form2 is the form being shown
    2. 'Form1 is the form it will stay on top of
    3. Form2.Show , Form1

  5. #5

    SetWinword

    See my question on Setwinword and Windows XP.

    My problem is that this worked when I had win98 but i cant get it to work on win XP.

    Let me know of your success.

    PS I normally place the function call in the load procedure of the form that needs to be on top.

    Hope this helps

  6. #6
    I just read tyger's reply i'm going to try that!

  7. #7
    yes tygur's suggestion works even in XP
    how simple

    Doh!!

    Thanks very much!!!

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Vaxjo, Sweden
    Posts
    85
    Ok, now I feel like an idiot.
    Thanks!

    --Anders
    Reality is what you make up when you can't handle your fantasies.

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