|
-
Jan 5th, 2002, 06:10 PM
#1
Always On Top?
i have a program, the thing is i need it to always be on top no matter what other programs are launched! there will be no minimise option, the only time it will not be on screen is when it is closed!
how do i do this??
thanx in advance
-
Jan 5th, 2002, 06:16 PM
#2
Fanatic Member
You can accomplish this using the SetWindowPos API...
In a module place the following code:
Code:
Public Const HWND_TOPMOST& = -1
Const SWP_NOMOVE& = &H2
Const SWP_NOSIZE& = &H1
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)
Then in a function or, as in my example, the form_load event place the following code:
Code:
Private Sub Form_Load()
Dim lFlags As Long
Dim lStay As Long
lFlags = SWP_NOSIZE Or SWP_NOMOVE
lStay = SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, lFlags)
End Sub
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Jan 5th, 2002, 09:06 PM
#3
adim that question was asked a lot in the past so you can always use the Search engine in VBForums who is located to the top of that screen. Next time just search before posting and you will have a answer very fast,
Daok
-
Jan 5th, 2002, 09:14 PM
#4
Originally posted by DaoK
adim that question was asked a lot in the past so you can always use the Search engine in VBForums who is located to the top of that screen. Next time just search before posting and you will have a answer very fast,
Daok
This answer has been used before.
Before you answer a question please use the search engine of these forums.
Next time you consider answering a question please make sure this answer hasn't been posted before
Lesson: (I'm sorry that I'm aiming this to you again DaoK, I know I've treated you badly before )
There is no such thing as a stupid question only stupid answers!
-
Jan 5th, 2002, 09:20 PM
#5
I know, I do not yell to him it's just because he is new to VBforums and I want to tell you some "feature" to optimize vbforums.com
-
Jan 5th, 2002, 09:28 PM
#6
Originally posted by DaoK
I know, I do not yell to him it's just because he is new to VBforums and I want to tell you some "feature" to optimize vbforums.com
I was only joking DaoK
-
Jan 6th, 2002, 01:14 AM
#7
try this ,
Private Declare Function SetWindowPos Lib "user32" Alias "setwindowpos" (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) As Long
Public Sub FormAlwaysOnTop(frm As Form, ontop As Boolean)
If ontop Then
SetWindowPos frm.hwnd, -1, (frm.Left / Screen.TwipsPerPixelX), (frm.Top / Screen.TwipsPerPixelY), (frm.Width / Screen.TwipsPerPixelX), (frm.Height / Screen.TwipsPerPixelY), 1
Else
SetWindowPos frm.hwnd, -2, (frm.Left / Screen.TwipsPerPixelX), (frm.Top / Screen.TwipsPerPixelY), (frm.Width / Screen.TwipsPerPixelX), (frm.Height / Screen.TwipsPerPixelY), 1
End If
End Sub
'frmresult is the form that 1 want to diplay it on top always and u can put your form name
Private Sub Command1_Click()
FormAlwaysOnTop frmresult, True
End Sub
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
|