Page 1 of 2

Checking if a there is a Full Screen app running?

Posted: Sun Mar 08, 2009 9:08 pm
by funnyguy
I want to hide my app's window if a full screen app (a game) is running. How do I check if there is a full screen app running?

Posted: Sun Mar 08, 2009 9:55 pm
by funnyguy
As in hide my always on top window when the user starts a game

Posted: Sun Mar 08, 2009 11:13 pm
by Mistrel
You don't mess with other people's applications to give yours priority. It's the user's responsibility to decide what windows should be on top.

But even with sticky windows there is a z-order. Just sticky yours and bring it to the top.

Posted: Mon Mar 09, 2009 3:06 am
by funnyguy
What do you mean? :shock:
Mistrel are you like off focus or something?

I need the code for my Clock...

Posted: Mon Mar 09, 2009 4:36 am
by Mistrel
I misread your question then. I thought you were asking how to push someone else's program to the back if your game was full screen.

In that case it's the other application's responsibility to set itself as the foreground window at the top of the z-order (even if other windows are stickied). I don't see how you would be able to tell the difference between a full screen game and a window that's just taking up the whole screen.

Can you give an example where this is a problem?

Posted: Mon Mar 09, 2009 4:37 am
by idle
Get the foreground window and its Rect, then test to see if it overlaps your window.

Code: Select all


hwnd = GetForegroundWindow_()
rc.RECT 
GetWindowRect_(hwnd,@rc)

rc\left
rc\top
rc\width
rc\height

;then test if over lapped 


Posted: Mon Mar 09, 2009 5:14 am
by Mistrel
If it's already overlapping his window then why would he need to hide it?

Posted: Mon Mar 09, 2009 6:20 am
by Rescator
*shrug* maybe to turn off graphic updating etc. for a more "friendly" app? That's what I would do, no need to waste cpu if it can't be seen, and the user would appreciate the game getting some more cpu cycles.
idle's code isn't that bad, but I'm pretty damn sure there is a API somewhere one can query as well (for example good screensavers known when not to start, like when a fullscreen app is running, no idea how they get that state info though)

Posted: Mon Mar 09, 2009 10:40 am
by Mistrel
Rescator wrote:like when a fullscreen app is running ..
Are you referring to a full screen application or a program which is running in as full screen exclusive? With the exception of full screen exclusive, which wouldn't be an issue to begin with, I don't see how you would be able to identify a legitimate window taking up the screen (like Word/Excel) vs a game.

Posted: Mon Mar 09, 2009 11:05 am
by Kaeru Gaman
for example good screensavers known when not to start, like when a fullscreen app is running, no idea how they get that state info though
to my knowledge, this is not an issue of the screensaver, but an issue of the fullscreen-app that sets a flag for the API handling this.
e.g. in GOM-Player you set a flag "disable screensaver while playback" in the preferences.
in some readmes of games I found the hint, to disable the screensavers if the switching on/off caused problems with the grafix.

additionally, there are multiple ways to do some "fullscreen".
a game can request some 'real' fullscreen,
or it could open a window and maximize this, changing main resolution or not,
or it can even output to the desktop background, what some older Sid Meiers's products seem to do.

idle's code is a nice approach, though I'm not sure if the foreground-thingy applies to all kinds of fullscreens on all WinOS.
I would test it against Civ3 on Win2K....
(on win2K a fullscreen really was a different graphic mode with an own output.
from XP on it's integrated as a maximized window, what changes the handling somehow.)

regarding all this, I think it's a rather desperate job to determine if you should call the current top output some "fullscreen" or not.
I would recommend a very conveniant hotkey to switch the visibility of the clock on/off.

Posted: Wed Mar 11, 2009 5:02 pm
by idle
off topic
Rescator wrote:(for example good screensavers known when not to start, like when a fullscreen app is running, no idea how they get that state info though)
you can always get the state but I don't think you can always disable it this way, probably depends if it's password protected.

You can also set it directly in the registry.

Code: Select all

result.l

retval = SystemParametersInfo_(#SPI_GETSCREENSAVEACTIVE, 0, @result, 0)

If result 
   lActive.l = #False  ;disable it
   retval = SystemParametersInfo_(#SPI_SETSCREENSAVEACTIVE, lActive, 0, 0)
EndIf  


Re: Checking if a there is a Full Screen app running?

Posted: Thu Mar 12, 2009 4:11 am
by PB
> How do I check if there is a full screen app running?

I saw this once on Usenet and took a snapshot. I can't find the actual post
anymore with Google Groups for some reason. Maybe it was removed?

Image

Posted: Thu Mar 12, 2009 7:58 am
by Mistrel
Some maximized window applications may not have a caption or thickframe. It's still a guess based on arbitrary visual styles.

Posted: Thu Mar 12, 2009 4:58 pm
by Rescator
I'm a bit confused by the original post.
I tested with one of my own apps which has a tool window (no title, sticky mode etc) it stays on top of everything, but if I do a fullscreen (like a movie player) it does not stay on top. Windows does this automatically.

So if the original app mentioned still stays on top then something not so system friendly is going on and some other window flags should maybe be used?

Also, if it's a clock I assume it only redraws once each second (anything else is a waste of resources).

And remember, if the user minimizes/hides the clock, it's smart to skip past the drawing part in the code until it's restored again.

...So the best solution is to...change nothing? *laughs*

Posted: Fri Mar 13, 2009 10:10 pm
by Mistrel
Rescator wrote:.. but if I do a fullscreen (like a movie player) it does not stay on top. Windows does this automatically.
If you set your application to on-top and it's higher in the z-order it will display on top of other on-top windows.