top | item 2331645

How do I create a topmost window that is never covered by other topmost windows?

108 points| gus_massa | 15 years ago |blogs.msdn.com | reply

51 comments

order
[+] RyanMcGreal|15 years ago|reply
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|15 years ago|reply
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|15 years ago|reply
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."
[+] CountSessine|15 years ago|reply
Did I say tomorrow? Tomorrow's Saturday, isn't it? I meant Monday. You can do a bit of time this weekend, can't you?
[+] DanielBMarkham|15 years ago|reply
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|15 years ago|reply
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...

[+] recoiledsnake|15 years ago|reply
Hint: Don't install software you think is crap. If it annoys you, uninstall it immediately, maybe drop the author a note why you did so. That includes Windows. Return that modem to Sprint, let them know their software sucks.You don't really have to use it.

I don't seem to have the problems that you're encountering, because I pick and choose software. No Quicktime, iTunes, RealPlayer or other annoying BS. Blaming Windows for your troubles is folly, those automatic updates you get keep your PC and others around secure and prevent them from becoming spambots, which will affect you even if you use Linux.

>..Vendor/programmer-induced interruptive bullshit.

The minute Microsoft even contemplates that, there will be long posts on here about how MS is screwing with developers and controlling users freedom with their monopoly.

And what's GC got to do with your point?

[+] maxklein|15 years ago|reply
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|15 years ago|reply
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.)

[+] timrobinson|15 years ago|reply
This would beat the "enumerating all the windows in the system and calling ShowWindow(SW_HIDE)" program, but not:

"setting their program as the screen saver, disabling the mouse and keyboard devices, and then invoking the screen saver on the secure desktop."

or

"enumerating all the processes on the system, attaching to each one with debug privilege, and suspending all the threads."

[+] lukesandberg|15 years ago|reply
You are joking right?

Because i could still just have my process kill your process and take over exclusive screen access... there's no winning this game.

[+] shimonamit|15 years ago|reply
Unfortunately that is not the case. Things like NetMeeting and other remote desktop control apps do the same.
[+] Natsu|15 years ago|reply
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|15 years ago|reply
And what is that obscure method?
[+] jrockway|15 years ago|reply
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!)

[+] adn37|15 years ago|reply
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_|15 years ago|reply
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|15 years ago|reply
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|15 years ago|reply
What if two applications has checked this box? That's the core of this article.