Community discussion forum
Always on top
-
This thread is for discussions of Always on top.
-
Advertisement
Simply the fastest line-level profiler for .NET ever
“The low overhead means it has minimal impact on the execution of my program”
Mark Everest, Development Team Leader, Renault F1 Team Ltd.Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now
-
6 years agoby
Rollershade
Colin Harman MACITP
West Sussex, England, AustraliaJoined 6 years agoi get argument not optional when i call this "Call MakeTopMost"
i have the other code as per the example, but still makes no difference, is this because i am using an mdi form as well as this form, the form is not an mdi child tho!
any ideas?? -
Basically you hwnd is a Handle (Pointer) to a window object, It being a long you must first create the pointer then send it.
Good Luck! -
6 years agoby
guitargod311
guitargod311
West Warwick, Rhode Island, United StatesJoined 6 years agoI agree with Rollershade, but this works fine, try it!:
Call MakeTopMost(hwnd)
Im not sure if the other function will work the same way, but this one works! -
All this is very nice, but it comes with a very annoying side effect. When the user
Alt-tab's to another application, the "always-on-top" window stays annoyingly on
top of the other application.
VB doesn't even give you an event to tell you that you app is no longer on top.
Got any ideas? -
Dude thats the point of this, that the window stays on top of other apps..
If you want the window to just stay on top of windows in your app, use
show formName,1
to show it as a modal form -
You have to put
Code:
MakeTopMost (hwnd)
in your code, not just
Code:
MakeTopMost
James, EXCELLENT ARTICLE! Helped me a lot! -
Guys, can you please tell me if there is any code with the same functionality that works in ASP (Active Server Pages).
-
works very nice
but could you help me to understand want does every line of this code means and why is it there?
thanks
btw i am a begginer -
6 years agoby
bengarrion
James Shawcross
Manchester, England, United StatesJoined 6 years agoonce i understood a bit of vb this was very easy to implement, i put the form on top state in the form load and it worked, i suppose you could set the form on top and normal state in to a check box
-
Just a hint to people who use this...
On Win 98 -> XP
1)ALT-TAB
2)Select any explorer app (or other, didn't bother to test)
---All you need to do is get to the quichlaunch bar!!
3)Start-bar pops up (with Quicklaunch attached)
4)Click Desktop short cut.
Hay Presto everything minimized including your ontop! app.
(Only tested on XP, but I assume it'll work on any desktop quichlaunch shortcut) -
I have encounted a problem when I showing another form using "form1.show vbmodal".
form1 cannot be shown.
How to keep the main form always on top of other application? and the child forms can show on top the main form.
Thanks! -
hi!
basically you can't do it in asp as the code is executed on your web server and not on the client machine.
Anyway, if you want to get a modal popup window you can add this code to the body tag of your popup :
<body onblur="window.focus();">
Cheers,
Hervé -
Hi
Here it is
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
-> declaration of the API function SetWindowPos taken from the "user32" library
Private Const HWND_TOPMOST = -1
-> constant to specify the window will be on top
Private Const HWND_NOTOPMOST = -2
-> constant to specify the window won't be on top
Private Const SWP_NOMOVE = &H2
-> constant to specify that the parameters x and y passed to the SetWindowPos function have to be ignored (keep the current x and y of the form)
Private Const SWP_NOSIZE = &H1
-> constant to specify that the parameters cx and cy passed to the SetWindowPos function have to be ignored (keep the current width and height of the form)
Private Const TOPMOSTFLAGS = SWPNOMOVE Or SWPNOSIZE
-> constant designed to pre-compute the OR logical operation of the SWPNOMOVE and SWP_NOSIZE constants (applying this constant will apply the two flags in the same time)
Public Sub MakeTopMost(hwnd As Long)
-> declaration of the MakeTopMost sub with the input parameter hwnd (handle window)
SetWindowPos hwnd, HWNDTOPMOST, 0, 0, 0, 0, TOPMOSTFLAGS
-> call of SetWindowPos
-> don't forget that the four 0 corresponding to the x, y, cx and cy parameters are ignored because of the TOPMOST_FLAGS
End Sub
It's the same for the other function, but the hWndInsertAfter which is set to HWND_NOTOPMOST
I hope this will help you
Cheers,
Hervé -
Sorry i missed and i reply your question to the message post by leokth ... check there
Cheers,
Hervé -
Sorry I missed ...
I wanted to reply to the mssage posted by zoglchaim ...
And I have no answer to your question yet.
Cheers,
Hervé -
Hi
I haven't try with mdi/mdi childs forms but if you want to get the handle of a form you can get it like this:
m_lHwnd = MyForm.hwnd
as the MyForm is your target form
Hope this will help
Cheers,
Hervé -
hi
I am facing problem with this code.
the form name is FrmTip which should always on top
The Form1 has tow textbox control
say text1 and text2 both have some tool tips
in the gotfocus of the text box event i calls the frmtip
by the following code
Private Sub Text1GotFocus()
FrmTip.Label1.Caption = Me.ActiveControl.ToolTipText
MakeTopMost FrmTip.hwnd
End Sub
Private Sub Text2GotFocus()
FrmTip.Label1.Caption = Me.ActiveControl.ToolTipText
MakeTopMost FrmTip.hwnd
End Sub
and also both the forms are Mdi Child forms
Please help me
if give frmtip.show command in the above event then the focus is in frmtip form only.
i want to use frmtip form as a tips form.
Please help as earyly as possible
My email id is S_Muhilan@hotmail.com
with regards
S.Muhilan
Mumbia-india.
Waitting for ur reply -
How can I add Command to my application in "send to" menu for any file type. I explain my problem here.
If the user right clicks on the file, the "Send To" menu comes under windows. I want to add "Send to Dwijen's Application" text in that menu and then when the user clicks on that command from "send to" menu, the windows explorer should launch my program saying the filename which is sent to my application. -
Simple to do, but not sure what it has to do with always on top.
Copy this code to a new form...
Option Explicit
Private Sub Form_Load()
MsgBox Command$
End
End Sub
Now just make your EXE and copy a shortcut to the "SendTo" directory. Under Win2K its C:\Documents and Settings\Suicidal\SendTo
Hope this helps.
Steve.
PS. Cheers for the code on always on top - has been useful. -
After adding this code, the form hides behind all other windows, doesn't show in the taskbar and won't close. -_-
-
-
the path for win98 is c:\windows\sendto\
a path that should also work for windows2k is
c:\documents and settings\all users -
didnt make any difference
-
where do i put that bit?
-
lol
-
lol thanks that worked perfect
-
Here is an exemple of use :
' ---------------------------------------------------
' FORM frmMapSearch
' ---------------------------------------------------
Private Sub Form_Activate()
MakeTopMost Me.hwnd
End Sub
The result is that when the form is drawn screen the Sub MakeTopMost will be called and then it will act as a modal form -
dropped this code into my form, cut and paste, and worked perfectly ... form stays on top of all other windows now ... even other forms in same app.
-
yeah, but can you do it in c in linux?
-
Example of call:
Call MakeTopMost(Me.hwnd) -
I also want to be able to interact with my application while this application stays on top. Anyone know how to do that?
I.e. if I put this function into the form I want to stay on top of all forms. If I use this function inside another application, it will not allow me to manipulate the screens of that application.
Thanks -
I use a MDIform with some child forms. I wanted one of these child forms to stay on top of the others, but the code only works if the function is called from the MDIform, otherwise it just doesn't work. To solve the problem I had to set the MDIChild property of the form to false, but esthetically it didn't look good. If there is any way to get the code working with a child form it would fit perfectly to me.
-
The above code plus the following makes a very useful combination of floating the ENTIRE MS ACCESS WINDOW rather than just one of the MDI forms.
Code:
Option Explicit
'API Declaration
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
sub RaiseAccess()
Dim hwnd As Long
'Find the MS ACCESS WINDOW
hwnd = FindWindow("OMain", "Microsoft Access")
If hwnd <> 0 Then MakeTopMost (hwnd)
'Then use MakeNormal(FindWindow("OMain","Microsoft Access") to bring it back down
end sub
Post a reply
Quick links
Recent activity
- Mandy Bradley replied to Loop help needed
- Chris Hsu replied to How can I execute server-si...
- anu anand.lv replied to Excel Oledb Engine and VB.NET
- Rafeeque Ahmed replied to HELP ME, URGENT RESPONSE
- anu anand.lv replied to we search the company in I...
- chandradev prasad replied to how to select item to datag...
Enter your message below
Sign in or Join us (it's free).