Form always on top 
Author Message
 Form always on top

I need to create a form that will under any and all circumstances be on
top, even on top of other programs. I have seen this in some other
program but can't find out how this is done.
TIA!
Abstract.



Tue, 12 Sep 2000 03:00:00 GMT  
 Form always on top

I think you may want to check out the SetWindowPos function - it has
certain flags you can set to ensure that the window always remains on top .
Let me know if you have a problem .
Regards,
 Priya
 Trisoft Design
 E 30 Connaught Place
 New Delhi 110 001 - India
 Tel: 372 5407, 373 8651, 373 8653 Fax: 372 5407

 Internet:http://www.spindia.com/



Quote:
> I need to create a form that will under any and all circumstances be on
> top, even on top of other programs. I have seen this in some other
> program but can't find out how this is done.
> TIA!
> Abstract.



Wed, 13 Sep 2000 03:00:00 GMT  
 Form always on top

Add the following to a BAS module:

Public Declare Function SetWindowPos Lib "User32" _
        (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, _
         ByVal x As Long, y As Long, cx As Long, cy As Long, _
         ByVal wFlags As Long) As Long

Public Const SWP_NOMOVE = &H2, SWP_NOSIZE = &H1, HWND_TOPMOST = -1,
HWND_NOTOPMOST = -2

Public Sub OnTop(hWnd As Long, Optional bOnTop As Boolean = True)
    If bOnTop 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

Now put this in your form (for example in the Form_Load event):

    OnTop Me.hWnd

("OnTop, Me.hWnd, False" to return to normal)

to make your form stay on top. You could also use a checkbox to allow the
form help "onTop" or not.
e.g. Add a checkbox to the form and put the following in the Click event:

    OnTop Me.hWnd, Not Check1.Value = 0

Enjoy,

John

Quote:

>I think you may want to check out the SetWindowPos function - it has
>certain flags you can set to ensure that the window always remains on top .
>Let me know if you have a problem .
>Regards,
> Priya
> Trisoft Design
> E 30 Connaught Place
> New Delhi 110 001 - India
> Tel: 372 5407, 373 8651, 373 8653 Fax: 372 5407

> Internet:http://www.spindia.com/



>> I need to create a form that will under any and all circumstances be on
>> top, even on top of other programs. I have seen this in some other
>> program but can't find out how this is done.
>> TIA!
>> Abstract.



Sun, 17 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Make a form always on top - always

2. Hide a Form's Titlebar and Make Form Always on Top

3. Keeping a Form Always On Top

4. VBA Form Always On Top

5. Form always on top

6. Form always on top

7. How I can make an Child-Form always on top

8. modeless form, always on top?

9. Form - Always on top

10. Form Always On top

11. Form - always on top??

12. Form always on top

 

 
Powered by phpBB® Forum Software