Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++MFC
The application I am working on is a MFC standalone application. I need to take some action based on the applications running in fullscreen on Windows. For example if mspaint is opened in fullscreen or any other application is opened in fullscreen. Below is the code snippet
    HWND hForeGndWnd = ::GetForegroundWindow();
    if (hForeGndWnd == NULL)
        return FALSE;
    RECT deskRect = {0};
    HWND hDesktopWnd = ::GetDesktopWindow();
    if (hDesktopWnd)
        ::GetClientRect(hDesktopWnd, &deskRect);
    WINDOWINFO wi = {0};
    ::GetWindowInfo(hForeGndWnd, &wi);
    if ((wi.rcClient.left == wi.rcWindow.left && wi.rcWindow.left == deskRect.left) &&
        ( == && &&
        ((wi.rcWindow.right-wi.rcClient.right <= 2) && wi.rcWindow.right == deskRect.right) &&
        ((wi.rcWindow.bottom-wi.rcClient.bottom <= 2) && wi.rcWindow.bottom == deskRect.bottom))
        return TRUE;
This logic works fine for all applications except windows media player. If windows media player on desktop is running in fullscreen then this logic fails whenever there is display controls (play, pause etc) is in picture and works if they are not.
Please do the needful.
Posted 21-Jan-13 17:28pm
Edited 23-Jan-13 19:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think you need to use GetWindowPlacement[^] API.
The function will tell you the current state of the window. In you case, if the window is just stretched to the size of the desktop, your function will still return TRUE.
wp.length = sizeof(WINDOWPLACEMENT);
if(::GetWindowPlacement(hForeGndWnd, &wp) && wp.showCmd & SW_SHOWMAXIMIZED)
    return TRUE;
On the side note there are two possible bugs in your code. First, you need to set the cbSize member to sizeof(WINDOWINFO) before calling this function (wi.cbSize = sizeof(WINDOWINFO)). Second, you need to test the return code of GetWindowInfo
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I'm sure your logic will fail for all media players because the actual media being played is an overlay on top of the player window. So in full screen, the player window is not in full screen, but the overlay is in full screen.
For the Windows Media Player, there are several COM interfaces available for you to use.
The method you're looking for is IWMPPlayer::get_fullScreen.
Calling this method could be a little complicated.
You can start here - Windows Media Player Object Model Reference[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Shai Vashdi 480
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 163
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353

Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid