|
-
Aug 22nd, 2000, 06:43 AM
#1
Thread Starter
Member
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 ?
-
Aug 22nd, 2000, 06:47 AM
#2
Addicted Member
Hi,
try:
and this will keep your second form on top util you close it down.
Hope this helps
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 22nd, 2000, 07:06 AM
#3
Thread Starter
Member
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.
-
Aug 22nd, 2000, 07:09 AM
#4
So Unbanned
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
-
Aug 22nd, 2000, 07:10 AM
#5
Addicted Member
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]
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 22nd, 2000, 07:12 AM
#6
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|