How To Keep App On Top? 
Author Message
 How To Keep App On Top?

I am attempting to create a small personal time tracking utility using
Visual Basic 5.  I would like it to always show at the top of the screen on
top of any and all other applications.  Like the windows task manager I
would like it to remain on top of all other applications and have not been
able to find a way of doing this.  I assume it would require the use of an
API but have been unable to find one to work.  I tried using the
SetWindowPos and other declarations but all that seems to do is place the
window on top of other windows within the same application.

Any ideas?  Resolution will guarantee the person who solves this problem a
free copy of the software being developed.

Thanks
Wayne Devries
EXceligent Software




Sun, 11 May 2003 03:00:00 GMT  
 How To Keep App On Top?
Wayne,

Use the SetWindowPos with HWND_TOPMOST.

A quick example from some code I use.

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

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20

Private Sub WindowOnTop_Click()

    If TopWindow.Value = vbChecked Then
        SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
    Else
        SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
    End If

End Sub

---
Hope this helps,
Mark

Quote:

> I am attempting to create a small personal time tracking utility using
> Visual Basic 5.  I would like it to always show at the top of the screen on
> top of any and all other applications.  Like the windows task manager I
> would like it to remain on top of all other applications and have not been
> able to find a way of doing this.  I assume it would require the use of an
> API but have been unable to find one to work.  I tried using the
> SetWindowPos and other declarations but all that seems to do is place the
> window on top of other windows within the same application.

> Any ideas?  Resolution will guarantee the person who solves this problem a
> free copy of the software being developed.

> Thanks
> Wayne Devries
> EXceligent Software





Sun, 11 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. how do you keep a vb app always on top

2. Keeping app on top

3. Keep App on Top?

4. Keeping a VB App on top?.?

5. How to keep Office toolbar, taskbar on top of VB app

6. Can't keep forms on top of my apps

7. How to keep Office toolbar, taskbar on top of VB app

8. Making my startup-app keep the focus/interference from other startup-apps

9. Can a Form or 2nd DirectX app be show over top of DirectX App

10. How do I keep My form on top?

11. Keeping a Form Always On Top

12. Address Book Window - Keeping On Top

 

 
Powered by phpBB® Forum Software