Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep a form "always on top"? 1

Status
Not open for further replies.

Stopher

Programmer
Jan 12, 2002
29
0
0
US
Can anyone tell me how to keep a form on top of everything else please!?!?!?!?!
;) Stopher
 
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)

Private Sub Form_Activate()
'KPD-Team 1998
'URL: 'E-Mail: KPDTeam@Allapi.net
'Set the window position to topmost
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
 
Try
Form.show vbModeless, Me
in VB6.

It's a lot easier.

 
Easier, yes. But doesn't solve the problem as stated in the original question. It merely keeps the window on top of other windows belonging to the your application. Windows belonging to other applications will quite happily obscure it.

 
Well, it might do just what he requires. In my experience, when people ask that question they generally mean within their application. And I'm not sure he meant it that literally anyway.
 
I needed it both within the program and outside the program for different projects. They both worked great! Thanx
;) Stopher
 
I have a little different situation. I have a program that uses MDI. Neither of these options work. Is there any way to keep a form on top in an MDI environment?

-T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top