The Concept of Top Most, how useful is it really?

R

Robin Tucker

I have a scenario that is to be totally honest, doing my Gnads in. The only
control I have over window Z ordering in VB.NET is by using "TopMost=True",
or "TopMost=False". There is no "z-order" concept that I can play with
apart from this single binary choice.

Now, think about where it might be useful to have fine grained control over
Z order: I have a main form, which pops up modeless "property" windows. I
want these property windows to remain in front of the main form because
otherwise it might be easy for a user to "lose one" behind the main form. I
also run a thread that needs to pop up a modal progress bar every now and
then. I want this to be top most of course when it's running, but I don't
want it to be topmost if I need to display an error form or message of some
kind while the thread is running, I want the error form to be topmost.
When the user presses F1 for help, I obviously want the help to be topmost.
I do not want any of my windows to remain topmost when the user launches
another process.

Now this might seem like a complex scenario, but in fact I think it's
probably a fairly common one. I'm not comfortable with piddling about with
the topmost property continually to micro-manage form visibility, when I
should simply be able to give a number on a form property that gives some
kind of Z order priority to each of my forms, relative to my executable.

Any ideas on how to manage these situations? TopMost does exactly what it
says on the tin, unfortunately!
 
S

steve

|I have a scenario that is to be totally honest, doing my Gnads in. The
only
| control I have over window Z ordering in VB.NET is by using
"TopMost=True",
| or "TopMost=False". There is no "z-order" concept that I can play with
| apart from this single binary choice.

| Now this might seem like a complex scenario, but in fact I think it's
| probably a fairly common one. I'm not comfortable with piddling about
with
| the topmost property continually to micro-manage form visibility, when I
| should simply be able to give a number on a form property that gives some
| kind of Z order priority to each of my forms, relative to my executable.

i understand your frustration. it can be done but i'd recommend the
following first:

you could think about making your main form an mdi form wherein the
other/child forms will be displayed and *never* go behind it. second, your
progress bar form should be set to topmost and your error handler form
should also. the error form will *always* be the most recent form displayed
and therefore the topmost visible. i don't see *any* micro-managing at all.
that type of management *would* be needed if you *did* start to set the
z-order of windows...you'd need a scheme/algorhythm to discover the
appropriate order to set for *every* window. how you open the forms too, is
very important...i.e. i'd open the error form as dialog (a.k.a.
form.showdialog() ) while the progress bar form should *only* be shown
(form.show() ).

if you don't want to go the mdi-route, you could use a combination of
topmost and/or show/showdialog with all your forms to get the results you
require.

i do agree that a bit more suffistication with window layering would be
nice, but this only comes to my mind as problematic under *far* more complex
ui contraints that the bulk of developers will never know...and, i've only
run across 2 occasions in 15 years of programming...both resolved more
easily through other means than tinkering with z-order.

hth,

me
 
C

Chris Dunaway

Robin said:
the topmost property continually to micro-manage form visibility, when I
should simply be able to give a number on a form property that gives some
kind of Z order priority to each of my forms, relative to my executable.

Why don't you do exactly that!! Create an Extender Provider that will
add a ZOrder property to your forms. Then in the form's constructor,
call the SetWindowPos api to set the ZOrder. It shouldn't be too
difficult.
 
R

Robin Tucker

Hmmmm thanks for the tip. I think I will ;)

Chris Dunaway said:
Why don't you do exactly that!! Create an Extender Provider that will
add a ZOrder property to your forms. Then in the form's constructor,
call the SetWindowPos api to set the ZOrder. It shouldn't be too
difficult.
 
C

Chris Dunaway

If you do, you might submit it to CodeProject as an article or MSDN or
something. at least post the solution here!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top