|
-
Nov 25th, 2001, 11:20 AM
#1
Thread Starter
Junior Member
Make a window always on top?
I am making a password program. I already have the code to disable ctrl+alt+del and alt+tab, but I am having the problem that the start menu still shows up over the window, and any programs you open after that show up over the window too, so the password window is nothing but a small nuisance. How do I make the window always on top, or fix this problem some other way? Thank you in advance!
-
Nov 25th, 2001, 11:25 AM
#2
Hyperactive Member
you can use the following code
Declarations
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)
Code
'this code makes the window stay on top
rtn = SetWindowPos(OnTop.hwnd, -2, 0, 0, 0, 0, 3)
'window will not stay on top with this code
rtn = SetWindowPos(OnTop.hwnd, -1, 0, 0, 0, 0, 3)
Josep Mª
-
Nov 25th, 2001, 11:26 AM
#3
Hyperactive Member
don't have vb 6 on this computer but i think this is done by setting your form to vbmodal.
something like form_load(vbmodal)
-
Nov 25th, 2001, 11:38 AM
#4
modal and always on top is not the same.
-
Nov 25th, 2001, 12:17 PM
#5
A modal form will not let to focus on the owner form without closing it first. An always on top window will remain on top of all other windows (unless it's another top-most window) even when it does not have focus.
-
Nov 26th, 2001, 05:44 AM
#6
Hyperactive Member
well, like i said, i never used it and have no vb6 or msdn on this pc...
-
Nov 26th, 2001, 06:49 AM
#7
-
Nov 26th, 2001, 06:52 AM
#8
Conquistador
i think he was talking to megatron...
-
Nov 26th, 2001, 07:18 AM
#9
Hyperactive Member
just ment that i only have vb.net on this pc no vb6 or earlier version
-
Nov 26th, 2001, 07:42 AM
#10
Frenzied Member
ALways on Top
Well, i patched up JoiJo's code for you, Jaded. Just plop the following in a module.
VB Code:
'====================================================
'====This code was written by joijo and macai=======
'====Use this code freely, but please leave the=======
'====comments. And credit would be nice, too. *wink*====
'====================================================
'Declarations
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)
'Actual Code
Public Sub KeepOnTop(F As Form, Enabled As Boolean)
If Enabled Then 'If the programmer wants the form on top.
SetWindowPos F.hwnd, -2, 0, 0, 0, 0, 3
Else 'If the programmer does want the form on top.
SetWindowPos(F.hwnd, -1, 0, 0, 0, 0, 3)
End If
End Sub
OK, i agree this is simple code. But it works. OK, now, all we need to figure out is how to startmenu toolbar thingy is controlled... bet its an API call. Ill go check and if i find something, ill post it.
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
|