Keeping a Form Box ALWAYS on TOP

How do you keep a form box to always stay on top no matter what other form box my application may pop up and thus trying to be on top?
I don't mean i want my form box to have focus when you are clicking to other form boxes, i just want it to remain visible while you go about working in other boxes.
I've set my form box to modal (so as to allow any other form box of my app to run while it is up), but i can't figure out the rest.
ljaquesAsked:
Who is Participating?
 
ljaquesAuthor Commented:
How do you get this OCX file to work with my vb app?
I have to register it?  I noticed it had a .REG file included with the zip but i have no idea how to get it to work..
Could you provide the steps?
0
 
ebussaCommented:
You can use Window API's to do this.  There is no OCX needed.  

To make a window "On Top" of ALL windows, try the following...

http://support.microsoft.com/support/kb/articles/q184/2/97.asp

To make a window "On Top" of a specific window, try this ...

http://www.mvps.org/vbnet/faq/form/floating.htm

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
chewhoungCommented:
Go to Project->Components->Browse and look for the component you just install and select OK.
0
 
ljaquesAuthor Commented:
chewhoung, I tried that but VB comes with a "THIS IS NOT REGISTERED" error.  It comes with a .REG file but I dont know how to install it.


0
 
ljaquesAuthor Commented:
chewhoung, I tried that but VB comes with a "THIS IS NOT REGISTERED" error.  It comes with a .REG file but I dont know how to install it.


0
 
chewhoungCommented:
extract OCX and DEP file to windows\system dir and select file from there. I tried my one  and its OK.
0
 
watyCommented:
Don't use any ocx, use the following code, it is easier and safest :

Private 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) As Long

Sub AlwaysOnTop(frmID As Form, OnTop As Integer)
   ' *** Pass any non-zero value to Place on top
   ' *** Pass zero to remove top-mostness

   Const SWP_NOMOVE = 2
   Const SWP_NOSIZE = 1
   Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
   Const HWND_TOPMOST = -1
   Const HWND_NOTOPMOST = -2

   If OnTop Then
      OnTop = SetWindowPos(frmID.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
   Else
      OnTop = SetWindowPos(frmID.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
   End If

End Sub

0
 
ljaquesAuthor Commented:
Thank you all....
0
 
watyCommented:
Why did you award the ocx instead of me, I gave you a complete working version witouth any OCX???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.