Making a form always stay on top. 
Author Message
 Making a form always stay on top.

How do you make a form always stay on top of another form?

Thanks,

Mike



Thu, 09 Mar 2000 03:00:00 GMT  
 Making a form always stay on top.

Quote:

> How do you make a form always stay on top of another form?

> Thanks,

> Mike

You may try this:

1. Open a new module by /Project/Add Module/
2. Put the following code in the module:

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

Public Sub StayOnTop(frmForm As Form, fOnTop As Boolean)

  Const HWND_TOPMOST = -1
  Const HWND_NOTOPMOST = -2

  Dim lState As Long
  Dim iLeft As Integer, iTop As Integer, iWidth As Integer, iHeight As
Integer

  With frmForm
    iLeft = .Left / Screen.TwipsPerPixelX
    iTop = .Top / Screen.TwipsPerPixelY
    iWidth = .Width / Screen.TwipsPerPixelX
    iHeight = .Height / Screen.TwipsPerPixelY
  End With

  If fOnTop Then
    lState = HWND_TOPMOST
  Else
    lState = HWND_NOTOPMOST
  End If
  Call SetWindowPos(frmForm.hwnd, lState, iLeft, iTop, iWidth, iHeight,
0)

End Sub

3. Make a call from the form you want to put on top:

        Call StayOnTop(frmForm1, True)

Hope this helps.

Jianming She



Thu, 09 Mar 2000 03:00:00 GMT  
 Making a form always stay on top.

I just finished up a class on Mastering Visual Basic 5.0, and they used a
Windows API call to get this to happen.  I don't have the exact code sitting
in front of me, but if you are interested let me know and I'll dig it up.

Tom Duff



Quote:
>How do you make a form always stay on top of another form?

>Thanks,

>Mike



Thu, 09 Mar 2000 03:00:00 GMT  
 Making a form always stay on top.

Quote:

> How do you make a form always stay on top of another form?

> Thanks,

> Mike

Look under modal and modeless forms.  One of those two properties will
work for you.

--

             \|/
            (o o)
--------oOO--(_)--OOo--------------
 Allen Sizemore & Yoli Chavira

 http://www.ionet.net/~panther        
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Fri, 10 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Make a form always stay on top

2. Help, I want my form ALWAYS staying on top of ANY other window

3. form that always stay on top

4. I'm trying to make the form always stay on top

5. Making Forms stay on Top

6. Making a form be always on top.

7. Does anybody know how to make an external applicatoin's window always stay on top

8. make an app always staying at the top

9. Making a Window stay ON TOP

10. Make a form always on top - always

11. Making Always On Top windows

12. Making the task bar NOT ALWAYS ON TOP BY PROGRAMIING

 

 
Powered by phpBB® Forum Software