Results 1 to 5 of 5

Thread: Forcing programs to be "Always On Top"

  1. #1
    Guest
    I'd like to create a program that could force other programs to be "Always On Top" and later not "Always On Top".

    The way I thought of doing it is after selecting a menu option in my program...it picks up on the next click of the mouse...it gets the handle of the program clicked on then...viola...makes that program float on top.

    Any ideas how? I have seen it done in the past but got no idea how!

  2. #2
    Guest
    Use the SetForegroundWindow API.

    Code for module.
    Code:
    Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
    Make a Form with 2 Command buttons and put the following code in them. Also create another Form called Form2.

    Code:
    Private Sub Command1_Click()
    
       Form2.Show     ' Show Form2
       Me.SetFocus    ' Give the Focus back to form1
    
    End Sub
    
    Private Sub Command2_Click()
    
       ' Make Form2 the Foreground Window.
       MyVar = SetForegroundWindow(Form2.hwnd)
    
    End Sub

  3. #3
    Guest
    Right, ok...

    Now how do you get the handle of the window that has just been clicked on? (It's not a window of my program...it could be notepad or the 3dfx TV application...

  4. #4
    Guest
    Yes, I believe it can be any Window that is running.

  5. #5
    Guest
    Hmmm...ok then...

    How would you get the handle of the IE/Netscape window you're running now?

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