

How do I create a topmost window that is never covered by other topmost windows? - gus_massa
http://blogs.msdn.com/b/oldnewthing/archive/2011/03/10/10138969.aspx

======
RyanMcGreal
This is a classic _arms race_ \- an escalating conflict over a _positional
good_ that by definition can only be enjoyed by one entity at a time. Other
positional goods include popularity in high school and military superiority
(from which we get the term "arms race" to refer to the escalating efforts of
multiple agents to achieve the good).

Generally, the only effective way to address an arms race is regulation: an
encorceable arms treaty, say, or a strict school uniform.

------
praptak
Yeah yeah, whatever. I don't want to hear about your problems. Having problems
is a sign of incompetence.

Just write me a program that always wins. While you're at it write me a
program that always prints the biggest number. I expect both by tomorrow.

~~~
jerf
I can't help you with that first one, but

    
    
      perl -e 'while(1){print 9;}'
    

A bit of a cheap shot as that is basically printing infinity without actually
calling it infinity, but I'm going to float this by on a claim that your boss
won't know the difference. "It's just not done yet, sir! Keep waiting. It's
printing a _really big_ number."

------
DanielBMarkham
I was going to chime in with my own ideas about solving this -- you can play
this game all day long and I'm sure inciting that kind of discussion that was
the intent of the author -- but this story about one particular request
accidentally illuminates a key problem with Windows: too many developers and
programs competing for one set of user eyeballs.

You'd think that would be a good thing, but far from it. What happens is that
every little developer writing any kind of tiny little app 1) wants money, and
2) wants to remind you how cool they and their app is by annoying you in
various ways. Sadly, the annoying part is usually done without any unkind
intent on the developer's part at all.

I have no problem with the money thing, aside from it being annoying to pay
for code that was just copied from MSDN and stuck in a wrapper, but the
blinky-beepy-gotta-be-on-top thing is driving me nuts.

The author uses an example of one guy who "knows" he wants the screen all the
time, but the real underlying architectural problem is much more subtle (and
worse) than that. Every program wants to tell the user something, maybe only
once a month or so. That'd be fine, if there weren't dozens if not hundreds of
programs running on the average setup.

I've been using Ubnutu for the last couple months, mainly because Windows has
become more like a video game, an XBox, than a serious operating system to me.
When I started my windows O/S up the other day to do some multimedia chore
after only two weeks without running it, _every program I ran had updates and
notices for me to attend to, including Windows itself_. That made a 5 minute
job take 2 hours, including the 15-minute boot time which was drug out because
once I bought a Sprint modem, Sprint in its infinite wisdom wants to intercept
and rework my network stack so they can "help me" use my computer better. This
involves Sprint needing updates, resetting my wifi preferences every time it
runs, forcing itself to run every time on boot, rewriting my access screens,
and doing something with memory, thread, and priority allocation during boot
that takes 5 minutes and can only be described from the user's standpoint as
evil. And for all of my invective, I know they didn't mean it that way! As far
as I know, they are honestly trying to provide assistance (assistance with
lots of branding and subtle control over user behavior. Sigh)

This is crazy. Windows has become like the web, only with one web page with
everything you might ever want to do on it crammed in there and you can't
navigate away. Somebody at Microsoft had better get on the ball and get rid of
atomic updates, garbage collection, and vendor/programmer-induced interruptive
bullshit. (Yes, there are ways to eliminate GC and the nightly install
crapfest, but that's a longer story) If they don't, Google is going to eat
their lunch. I'm afraid you can't have one O/S that is both extremely complex
and consistent across millions of different use-cases. At least not structured
like this.

~~~
wladimir
I agree this is crazy. Windows really needs a central infrastructure for:

\- program updates (polling for them, asking the user)

\- user notifications (grouped, not with a zillion different icons)

\- running tasks at certain times/conditions (yes, windows has this, but many
apps nevertheless insist on running their own scheduler service)

\- license server? (or at least, a way to launch these on demand, no need to
run adobe/flex/matlab/bla license servers when the program is not running)

Right now, every program wants to install its own background process (some
very bad ones want even more than one). This is very very annoying: programs
that are not running at the moment shouldn't steal memory and CPU time by
running something in the background.

It's too easy to turn your fresh windows installation into a ghetto. And it's
not only fishy backwater programs that do this, the big commercial
applications are just as guilty (yes, Adobe, I'm talking about you...).

Linux distributions and MacOSX have these things figured out for ages...

~~~
kevingadd
Last time I used OS X it didn't have program updates or user notifications
figured out. I had to use Growl for the latter, and apps had to individually
use Sparkle for the former, which is basically the same as the Windows
situation. I agree that Windows should have centralized solutions for these
problems, though.

~~~
varikin
Growl and Sparkle are the defacto standards for notifications and program
updates on Mac. They are very nice because I can control how I am notified
through Growl settings (no notifications) and apps tell me there is a new
update when launching (or polling while use). A recent version of Sparkle has
a new option that I think is genius, update on quit. This allows me to tell
the app that when I quit it, install the update. That way I don't have to wait
for the app to update and restart when I just want use the app for 5 minutes.

One problem with Growl is that if you don't have it installed, some apps
provide their own notifications. Then when you don't want any notifications
like me, you have to configure that in each app. So it is best to install
Growl and disable notifications.

Now with the app store on Mac, Sparkle might not be used as much in the future
because the app store will handle updates.

Overall, I think the OS X developer community has worked this out fairly well
on their own.

------
Natsu
Alas, I still work with a program where someone had the bright idea to play
tricks like this and, as a result, you can get error messages stuck completely
behind an unmovable topmost window.

Thankfully, there's one slightly obscure way to get Windows to move a window
that's completely behind another window, but many people don't realize there's
anything back there in the first place.

~~~
daten
And what is that obscure method?

~~~
Natsu
Right click it from the task tray and select move. Your mouse cursor will jump
over to the top of the window (even if you can't see the window) and you will
actually move the item you selected rather than the topmost window you appear
to be clicking on.

I called it "slightly obscure" because while the move option is perfectly
normal, I had no idea that you could still select a window that was completely
behind other windows.

EDIT: And no, "close" wasn't among the options for that error.

~~~
psykotic
Or you can select the window with alt-tab, press alt-space to open the window
menu, press 'm' to select 'move' and then use the arrow keys.

I use this all the time when windows go completely off screen and you can't
grab them with the mouse. That can happen in all sorts of surprising ways.

~~~
drv
And once you've moved it with an arrow key, you can then move it freely with
the mouse until clicking.

------
jrockway
The solution to this problem is to not let programs realize that there is a
such thing as a window manager. "You have an x by y rectangle to draw in.
There is no such thing as `other programs'. Enjoy."

Then the _end user_ can script these complex interactions in a way that
pleases him. Composibility is better than following an arbitrary spec.

UNIX gets this: I can program all my window interactions in Haskell. When
mplayer wants to be fullscreen, it gets it. Everything else... nope, sorry.

(Also, I have a solution! Run all the non-super-important programs in a VM.
Then minimize the VM when your super-important program wants attention. This
even composes properly when a more-super-important program comes along!)

------
maxklein
A solution would be to use DirectX and request exclusive access to the screen.
It's rather unlikely any of the other apps are doing this.

Using DirectShow it would not even be complex - could be done in just a few
lines of code.

~~~
kwantam
You just... don't get it, do you Scott?

(There is no way to win this game by giving the best solution to it. The
better you get, the worse you get.

In other words: the only way to win is not to play the game.)

~~~
enjalot
dll inject all the other programs?

rootkit and write your own display driver?

~~~
jrockway
Erase Windows and it shitty ecosystem and start over with code that the end
user can modify and improve?

------
adn37
Code injection (SetWindowsHookEx, WH_CBT) and API hooking allows to filter out
other programs requesting topmost display.

But this is intrusive. And it can be bypassed by other vendors, whether they
workaround it by using other APIs/tricks or unhook their own process' APIs at
runtime themselves.

As said here in this thread, the only way to ensure full control is to patch
the kernel (Window management related syscalls). And even there it's tricky to
be exhaustive.

VM is the safe way to go.

------
_debug_
I suppose it's issues like this that make tablet PC creators choose a single-
tasking (or rather, single-app-controls-the-screen) model?

------
philthy
I believe XCode (I may be confusing the interface with RunRev Cards thing from
a while ago though) has a simple check mark to make window a top most window
on Mac. But I'm not sure if they can be scaled. Some of the Logic Pro and
Final Cut tools function like this, where they are abovee everything.

~~~
bajsejohannes
What if two applications has checked this box? That's the core of this
article.

------
WalterBright
Please don't.

