Detect Running Fullscreen App

Good day Experts,

I have an application that runs in the background with an icon in the system tray.  When an event occurs, this application spawns a pop-up window created with the TOPMOST flag.  The problem is that since my window is designed to always be on top until the user interacts with it, it interferes with fullscreen applications.

What I need to do is detect if a fullscreen application is currently active so I can supress the pop-up.  As well, it would be benificial to detect when there are no longer any fullscreen apps running so that the pop-up can relay it's information at that time.  But the most important thing is to not show the pop-up when a fullscreen app is running.  A fullscreen app must be things like a powerpoint presentation as well as any fullscreen game or perhaps a command prompt is being run fullscreen.

Any assistance is appreciated, Thank you for your time.
LVL 4
r2farAsked:
Who is Participating?
 
jkrCommented:
This is just an idea, but could do the job:

BOOL IsFullScreenAppRunning () {

HWND hWnd = GetForegroundWindow();

RECT rc;
GetWindowRect(hWnd,&rc);

if ( rc.right - rc.left  == GetSystemMetrics(SM_CXFULLSCREEN) &&  rc.bottom - rc.top == GetSystemMetrics(SM_CYFULLSCREEN)) return TRUE;

return FASLE;
}
0
 
Dariusz DziaraProgrammerCommented:
What does it mean, fullscreen ? That it occupies whole screen area or that it has TOP window (probabely both) ?

You can use EnumWindows() to enumerate all top windows on the screen.
You can use GetWindowLong() to get window style (check if you have WS_EX_TOPMOST extended style)
and also call GetWindowPlacement() to check if window in SW_MAXIMIZE state or occupies whole screen
0
 
r2farAuthor Commented:
The criteria for fullscreen are that it takes up the entire screen covering all other windows, including covering the taskbar.  The only thing visible on the screen is that app.  This raises an interesting quandry with multiple-monitors though, but I will be satisfied if it just detects a fullscreen app that is currently being displayed on 'any' monitor and supresses the pop-up even if the desktop is visible on another monitor.  It would however be a bonus if a fullscreen app ran on a monitor other then the one which the taskbar resides, that the pop-up would still occur (but not my primary goal atm).


jkr -
Your method seems to work on a single monitor (had to replace SM_C*FULLSCREEN with SM_C*SCREEN).  It works with visual studio in fullscreen mode, but this method choked when I made a command console fullscreen.  The command console must be doing something different (seemed to change monitor resolution as it went fullscreen).

mrblue -
Enumeration has its benifits.  I tried your method but it seemed to think my tooltip control was fullscreen and visual studio in fullscreen mode was not.  I can understand why the tooltip window said it was TOPMOST, but not sure about why the maximize check triggered on it.  As well, visual studio does not seem to actually set itselfs as topmost when it is in fullscreen mode.


I will have to test this a bit more, Thank you both for your input.  If you know how MSN Messenger flags you as 'busy' when a fullscreen app or game is running, that is similar to what I am trying to do here, prevent the user being disturbed during a fullscreen session.  The biggest issue is trying the code when a full screen game is running, as well as when a powerpoint slide show is running.  Will get back to you in a day or so.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Dariusz DziaraProgrammerCommented:
Hm, so you need to check window position & size
0
 
mahesh1402Commented:
>>perhaps a command prompt is being run fullscreen.

Their is an undocumented function GetConsoleDisplayMode()..you can use that if you want to detect if console application is running in fullscreen mode.....you need to use GetModuleHandle/LoadLibrary and GetProcAddress to invoke this function in kernel32.dll.

e.g. something like :

BOOL GetConsoleDisplayMode (LPDWORD lpdwMode); // address of variable for current value of display mode

typedef BOOL (WINAPI *PROCGETCONSOLEDISPLAYMODE)(LPDWORD);
PROCGETCONSOLEDISPLAYMODE GetConsoleDisplayMode;

HMODULE hKernel32 = GetModuleHandle("kernel32");
GetConsoleDisplayMode = (PROCGETCONSOLEDISPLAYMODE)GetProcAddress(hKernel32,"GetConsoleDisplayMode");

....//use GetConsoleDisplayMode()

-MAHESH
0
 
r2farAuthor Commented:
Mahesh...
I am interested in suppressing the popup when the console is fullscreen.  The code you have here compiles but does not prevent the console from minimizing and giving focus to the pop-up when it recieves an event.  I took a look into the returned results and it is not stating that the console is fullscreen.  Perhaps it is dropping out of fullscreen before my popup gets to its 'fullscreen check' code?

Anyway, Supressing during OS run fullscreen console would just be a nice bonus, jkr's solution seems to work for the important parts, games and fullscreen windows applications.  When the console is fullscreen it registers a CCmdTarget class as the foreground window, is there a way to use that to find the bounding rectangle of the console?  if so I could probably rig jkr's code to detect a console app and check its rect.

Thank you all for your responses thus far
0
 
mahesh1402Commented:
Console application is having class name 'ConsoleWindowClass' ...

With running one console window if I try to get position of that console window using GetClientRect() then i get positions of Rect as (0,0,0,0) format while it returns appropriate position when its not in full screen.

invoking one console window you may try like :

CRect rect;
FindWindow("ConsoleWindowClass",NULL)->GetClientRect(rect);

same with GetWindowRect() and running console application in full mode returns positions in negeative.

this may helpful ?

-MAHESH
0
 
r2farAuthor Commented:
I will increase points and split between jkr and mahesh.  You have both provided insight that contributed to my final solution.
0
 
mahesh1402Commented:
split ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.