Important alert: (current site time 7/16/2013 2:02:07 AM EDT)
 

winzip icon

[ Form On Top ]

Email
Submitted on: 4/14/2002 7:29:31 AM
By: Brian Link 
Level: Intermediate
User Rating: By 42 Users
Compatibility: VB 5.0, VB 6.0
Views: 58404
(About the author)
 
     This will put your forms on top. Works good. It uses API calls to do this. Hope it helps you. Also Please visut my site, i got some video tutorials there about visual basic. http://www14.brinkster.com/computerteck/?p254
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/14/2002 9:33:30 AMAdam Szabo

Excellent!
Just what I needed.
Simple and to the point code. 5 from me!
(If this comment was disrespectful, please report it.)

 
4/15/2002 2:26:39 AMtony

We've seen this form on top api call many times and it's OK - if you want your form on top of every single window currently open, but this is rarely the case. Does anyone know a way to keep a form on top of only the forms in its own application?
(If this comment was disrespectful, please report it.)

 
4/15/2002 2:38:19 AMBrian Link

Just call up the funtion in each form, in the form_load
(If this comment was disrespectful, please report it.)

 
6/7/2002 3:08:43 PMSaryon

Wow. Amazing, EXACTLY what I was looking for, you're my savior!!!
(If this comment was disrespectful, please report it.)

 
6/10/2002 3:37:16 AMShawn Woods

Great job, Thanx for the code. 5 Globes (I wish people voted for quality code more often)
(If this comment was disrespectful, please report it.)

 
6/17/2002 5:23:24 AMCyberX

Fantastic job
(If this comment was disrespectful, please report it.)

 
7/28/2002 11:00:23 PMPB

Yay! your special!
(If this comment was disrespectful, please report it.)

 
8/24/2002 4:24:17 AMDiretto

To keep a form on top of the other forms in a project, uhmm... OH! Yea, in the Form_LostFocus event, put Form.SetFocus and your worries are over lol.
(If this comment was disrespectful, please report it.)

 
10/17/2002 7:17:03 AMDavid Goben

Tony, the following will set the form on top for just the app it's running in (will even autominimize when the main form is minimized):


Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const SWW_HPARENT = -8

Public Function SetToolBoxParent(TBoxHwnd As Long, PrntHwnd As Long) As Long
SetToolBoxParent = SetWindowLong(TBoxHwnd, SWW_HPARENT, PrntHwnd)
End Function


(If this comment was disrespectful, please report it.)

 
10/17/2002 11:41:06 AMDobnik Sebastjan

To keep modeless form on top of other use this in Form1:

Private Sub Command1_Click()
Form2.Show 0, Me
End Sub

Sebastjan
(If this comment was disrespectful, please report it.)

 
10/22/2002 12:32:22 PMStefan Carter

Thanks for the code.
(If this comment was disrespectful, please report it.)

 
1/4/2003 7:20:46 PM

Well not exactly what i was looking for. I need to make it so that my form resizes the desktop area so that it its not only on top bot also maximized windows wont show up behind it. Same thing with the Desktop icons. Although your code does do what it says....
(If this comment was disrespectful, please report it.)

 
6/11/2003 7:45:36 AM

I usually don't vote, but this time, it's what I needed.

In response to Tony, To control the order in which forms appear, can't you use the Zorder property...that is valid only for the project, not forms from other sources.
(If this comment was disrespectful, please report it.)

 
9/3/2003 2:28:04 AMAndron Smth

Public Sub Main()
Load Form1
Form1.show vbModal 'Makes the form stay on top of every window. Loaded by that Application. Windows in the background becomes unaccessible
end sub
(If this comment was disrespectful, please report it.)

 
11/28/2003 10:52:46 AM


(If this comment was disrespectful, please report it.)

 
4/25/2004 12:15:20 AMEamonn

Just what the Doctor ordered to solve my problem! Thanks for the great code! 5 Stars!!!
(If this comment was disrespectful, please report it.)

 
7/6/2004 11:11:25 AM

thank you very much.
EXACTLY what I was
looking for.
(If this comment was disrespectful, please report it.)

 
7/16/2004 12:08:53 PM

Great, keep up the great work, five stars.
(If this comment was disrespectful, please report it.)

 
8/3/2004 2:27:01 AMjsgoh

good...good...
(If this comment was disrespectful, please report it.)

 
8/10/2004 10:15:47 AMrBg

So how would you make it so that the form not be on top? Like if I wanted to have a check box that says always on top or no always on top??
(If this comment was disrespectful, please report it.)

 
3/26/2005 8:00:20 AM

Great job, man! Five stars from me!
(If this comment was disrespectful, please report it.)

 
8/13/2005 4:16:14 AMJeff Smith

Great job, exactly what I needed. 5 *s! Thanks!
(If this comment was disrespectful, please report it.)

 
11/14/2005 3:05:24 AMGlen

GG, Great Code
(If this comment was disrespectful, please report it.)

 
12/1/2005 12:44:15 AMWill Christ

Keep'em Coming! Five Globes!
(If this comment was disrespectful, please report it.)

 
12/9/2005 10:34:51 AMLan Pham

Thank YOUUUUUUUUUU!
(If this comment was disrespectful, please report it.)

 
1/6/2006 11:41:37 PMcurlyjoe

NICEEE.....
(If this comment was disrespectful, please report it.)

 
1/6/2006 11:42:24 PMcurlyjoe

NICEEE..... anw..ur site is broken. got any other site ? email 2 me please.. so i can check it out =)
(If this comment was disrespectful, please report it.)

 
1/21/2006 1:44:32 PMMatt DeKok

It does keep the form on top, but it won't let me close it if a timer was active.
(If this comment was disrespectful, please report it.)

 
3/10/2006 10:11:52 PMErwin Hasanuddin

Hello Brian Link,
My name Erwin, Iam newbie here
brian i have try to visit your web site, but the site is not there. Can you tell the true site, if it still there.
http://www14.brinkster.com/computerteck/?p254

BTW your code is great for me.
(If this comment was disrespectful, please report it.)

 
8/12/2006 1:24:10 PMGurpreet Singh Gambhir

i am a beginner and i hav found dat u are a professional programmer can u plz help me in learning vb i will b very thankful to u

regards
sunny
(If this comment was disrespectful, please report it.)

 
12/19/2006 5:40:29 PMRaj

I am using the following code and getting the following error can anyone help?

Dim MyBrowser As SHDocVw.InternetExplorer
MyBrowser = New SHDocVw.InternetExplorer
MyBrowser.Visible = True
Dim ieobject As Object
MyBrowser.Navigate("http://www.google.com")
ieobject = MyBrowser.Document()
MsgBox(ieobject.GetType().ToString())




I get the following error:

Error HRESULT E_FAIL has been returned from a call to a COM component.


(If this comment was disrespectful, please report it.)

 
3/1/2007 10:04:56 AMRodG

Pretty cool but when I press ctrl+alt+del the window task bar stays on top. Much better if the form stays on top of the windows task bar.....
(If this comment was disrespectful, please report it.)

 
9/23/2007 2:45:46 PMlerner

just what i needed. i am worcking on a jocke program that will thell the user to relax fore 3 minutes and will not let him tu use his pc
(If this comment was disrespectful, please report it.)

 
10/14/2007 4:21:58 AMlerner

to keep the form on top of ewery window just ad a timer whit interval=1 and and set the command to the timer so that the form will be on top as soon as it can
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.