[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Detect Running Fullscreen App

Posted on 2006-05-10
10
Medium Priority
?
908 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:r2far
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 16651791
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
 
LVL 8

Expert Comment

by:mrblue
ID: 16651878
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
 
LVL 4

Author Comment

by:r2far
ID: 16653012
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:mrblue
ID: 16653092
Hm, so you need to check window position & size
0
 
LVL 22

Assisted Solution

by:mahesh1402
mahesh1402 earned 800 total points
ID: 16655673
>>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
 
LVL 4

Author Comment

by:r2far
ID: 16659828
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
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16660788
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
 
LVL 4

Author Comment

by:r2far
ID: 16668221
I will increase points and split between jkr and mahesh.  You have both provided insight that contributed to my final solution.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16668236
split ?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question