Click to See Complete Forum and Search --> : Bringing Form to Front


Shan77
May 20th, 2001, 10:01 PM
How do I bring a form to the front and keep it there ??

Thanks in advance.

cksiow
May 20th, 2001, 10:15 PM
refer http://vblib.virtulave.net, there is a function called AlwaysOnTop in vbGeneralControl class which might help. Pass in the form handle, i.e. Form1.hWnd

HTH

Cimperiali
May 21st, 2001, 05:42 AM
..Or try this:

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: http://www.allapi.net/
'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

Go visit allapi.net. Their "Api-Guide" is usefull and free (send them a postcard is all they require for)

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.