Results 1 to 4 of 4

Thread: How do you make something stay above all other windows?

  1. #1

    Thread Starter
    Addicted Member krah's Avatar
    Join Date
    Jan 1999
    Location
    Arkansas, her hyuck!
    Posts
    163

    Cool

    I've heard it called "floating" a window. So, you know my question. How do you do it?
    Is it tired in here or is it just me?

    Ryan Williams
    -Using Vb6-

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey mate! you're in luck I've been using it lately (read: yesterday ), here it comes!

    Code:
    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)
    
    
    'To set on top:
    SetWindowPos frmMain.hWnd, HWND_TOPMOST, 0, 0, 0, 0, 
    SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    
    'To undo this:
    SetWindowPos frmMain.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    Gottagosleeping now, see ya!

    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    Guest
    If you want to set another window as the top most one, all you need is the handle (hwnd) of another program to make that program stay on top of all others. You can use the FindWindow api function to do it.

    Code:
    Private Declare Function FindWindow Lib "user32.dll" _
    Alias "FindWindowA" (ByVal lpClassName As Any, ByVal _
    lpWindowName As Any) As Long
    You can use it like this:

    Code:
    Private Sub Command1_Click()
         'Finds Calculator
         hWin = FindWindow(vbNullString, "Calculator")
         If hWin <> 0 Then 'If Calculator found...
         'Set the Calculator as topmost window
         SetWindowPos hWin, HWND_TOPMOST, 0, 0, 0, 0, _
         SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
         End If
    End Sub
    Not sure if you wanted this, but you said a window.

  4. #4

    Thread Starter
    Addicted Member krah's Avatar
    Join Date
    Jan 1999
    Location
    Arkansas, her hyuck!
    Posts
    163

    Talking

    Thanks mate! G'd-reply. You really hit the kangaroo on the head with that one! You're sharp as a boomarang! You deserve a trip to Out Back Steak House where we can kick back and have a couple of Fosters!

    hehe


    Hey...I kid because I love (in a programmer sort of way)!
    Is it tired in here or is it just me?

    Ryan Williams
    -Using Vb6-

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