-
I'm sure this one has been asked a million times already, but I need to know how to keep a form on top. I have a large form on screen, when I click a button a smaller form pops up and hovers about a bit, but when I click on a control on the main form again the smaller one disappears, I need it to stay visible until other events take place. Any ideas anyone ?
-
Hi,
try:
and this will keep your second form on top util you close it down.
Hope this helps
Shaun
-
Thanks, It does keep it open. However one problem, it doesn't allow me to return focus back to the main form so I can continue to type stuff in on the main form.
-
If have a form open then call a form like:
form2.show , form1
form1 will act like MDIForm, except form2 can go beyond form1's edges
but it will stay above form1 at all times
-
;) OK
Try this:
Code:
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Sub MakeNormal(Handle As Long)
'// Replaces the window in the ZOrder
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
Public Sub MakeTopMost(Handle As Long)
'// Sets the window in the ZOrder
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
then to make Form2 stay on top use:
Code:
MakeTopMost Form2.hwnd
and to return it to its normal state use:
Code:
MakeNormal Form2.hwnd
Hope this helps
Shaun
[Edited by S@NSIS on 08-22-2000 at 08:13 AM]
-
Or if you just want the form to be on top of your main form and not on top of all program windows you could just show it like this:
Code:
From2.Show vbModeLess, Me 'or the form you want it to be on top of
Good luck!