Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Desktop application needs focus when user is in metro

I have a desktop application (non metro). I need to get the user back to my application Desktop in some emergency situations (could mean life or death). How do I get focus back onto my application if the user is in a metro style application?

like image 236
megazord Avatar asked Nov 12 '22 10:11

megazord


1 Answers

Found this great sample code on MSDN.

It checks to see if the windows 8 start screen is visible or not. Check it out.

PCWSTR const _GetMonitorAppVisibilityString(MONITOR_APP_VISIBILITY monitorAppVisibility)
{
    PCWSTR pszAppVisibilityString = nullptr;
    switch (monitorAppVisibility)
    {
        case MAV_NO_APP_VISIBLE:
            pszAppVisibilityString = L"no apps visible";
            break;

        case MAV_APP_VISIBLE:
            pszAppVisibilityString = L"a visible app";
            break;

        case MAV_UNKNOWN:
        __fallthrough;
        default:
            pszAppVisibilityString = L"unknown";
            break;
    }
    return pszAppVisibilityString;
}

Follow this link to download the full sample c++ code (Visual C++ 2012/13): http://code.msdn.microsoft.com/windowsdesktop/Start-screen-visibility-b1a72059

like image 88
Software_Designer Avatar answered Nov 15 '22 05:11

Software_Designer