Shoutbox

Detect Full Screen application - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Detect Full Screen application (/showthread.php?tid=67047)

Detect Full Screen application by J-Thread on 10-07-2006 at 11:34 AM

A very short question: How can I detect that there is a full screen application running? I tried the following code:

code:
// Check if full screen app is running
bool IsFullScreenAppRunning () {
    HWND hWnd = GetForegroundWindow();

    if(!hWnd)
        return false;

    RECT rc;
    if(!GetWindowRect(hWnd,&rc))
        return false;

    return (rc.right - rc.left  >= GetSystemMetrics(SM_CXSCREEN) &&  rc.bottom - rc.top >= GetSystemMetrics(SM_CYSCREEN));

}

But that has got 2 problems:
1. It returns true if my desktop is the foreground window (i.e. there aren't really any windows)
2. There can be another window on top of the fullscreen window, and then this function returns false, which is not what I want.

Does anybody know how to fix this? Using GetClientRect doesn't work either:(
RE: Detect Full Screen application by Mnjul on 10-09-2006 at 01:47 PM

quote:
Originally posted by J-Thread
1. It returns true if my desktop is the foreground window (i.e. there aren't really any windows)
I believe you can test against this by comparing the hwnd returned by GetForegroundWindow with one returned by GetDesktopWindow(). :)
RE: Detect Full Screen application by ShawnZ on 10-09-2006 at 01:58 PM

Enumerate every HWND except GetDesktopWindow() to see if they have the metrics of the screen?


RE: Detect Full Screen application by J-Thread on 10-09-2006 at 02:51 PM

Both sound good but don't work...:(

Somehow, GetDesktopWindow() returns a different HWND then GetForegroundWindow() when my desktop is the foreground window (so all my windows are minimalized).

The problem with enumerating all windows is that EnumWindows uses a callback function to return the results. So I cannot use that in my IsFullScreenAppRunning() function to return either true or false...

Thanks for your help anyway;)


RE: Detect Full Screen application by Ash_ on 10-09-2006 at 05:06 PM

psuedocode

code:
H = GetForeGroundWindow()
  if (IsWindowVisible(H) and not IsIconic(H) and IsZoomed(H)) then window is Fullscreen


untested as i dont have any compilers installed atm but those 4 API calls should produce what you need.
RE: Detect Full Screen application by J-Thread on 10-09-2006 at 05:16 PM

Edit: Err I should test a bit more before posting... That code also returns true on maximized windows. The following code solves problem 1:

code:
// Check if full screen app is running
bool IsFullScreenAppRunning () {
    HWND hWnd = GetForegroundWindow();

    if(!hWnd)
        return false;

    if(!IsWindowVisible(hWnd) || IsIconic(hWnd) || !IsZoomed(hWnd))
        return false;

    RECT rc;
    if(!GetWindowRect(hWnd,&rc))
        return false;

    return (rc.right - rc.left  >= GetSystemMetrics(SM_CXSCREEN) &&  rc.bottom - rc.top >= GetSystemMetrics(SM_CYSCREEN));
}

But the second problem still exists...