Topmost property

Wirloff

Member
Joined
Mar 2, 2005
Messages
19
Location
Belgium
Programming Experience
1-3
Hi,

I know how the Topmost property works (keeps a form on the foreground), but is it possible to make a form topmost, only within the program itself..
It should disappear when opening an other application, but now it always stays on top, even when opening an other app...

Anyons knows how to solve this?
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
You can try setting the Owner property of the form that you want on top of the application. Try that and see if it's what you're after.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,328
Location
Sydney, Australia
Programming Experience
10+
An owned for behaves like the Find and Replace box in VS. It is always on top of the app's main window while still allowing you to access that main window, unlike a modal dialog, but will fall down the z-order with that main window as other apps are activated. This could be thought of as TopMost in the context of the application but not for the whole desktop.
 

Wirloff

Member
Joined
Mar 2, 2005
Messages
19
Location
Belgium
Programming Experience
1-3
Own solution

We have found another solution, and it's a really easy one..

Instead of using Form.show()

we discovered that Form.showDialog() does the thing that we wanted to do it :s

Extremely idiot, but it works :eek:
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,328
Location
Sydney, Australia
Programming Experience
10+
To clarify a few things for those having similar issues:

  • Setting the TopMost property to True causes a form to be shown on top of all other (non-TopMost) windows, even when it does not have focus, without preventing access to other windows. This is the default behaviour of the Windows Task Manager.
  • Setting the Owner property causes a form to be shown on top of its owner at all times without prevening access to the owner. This is the behaviour of the VS Find and Replace window.
  • Using ShowDialog() to display a form creates a modal dialog, which prevents access to the calling form until it is closed. This is the behaviour of a MessageBox.
 
Top Bottom