How to determine if a Metro app is currently displayed on the screen?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to determine if a Metro app is currently displayed on the screen?

  1. #1
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    831

    How to determine if a Metro app is currently displayed on the screen?

    I'm trying to determine (from my Win32 process) if a Metro (or a Modern UI) app is currently displayed on the screen. I found the IAppVisibility::GetAppVisibilityOnMonitor method that can do just that, and I even found a C++ sample, but my issue is that I'm compiling it with the Visual Studio 2008 that does not have the definitions for the IAppVisibility interface, so the following:

    Code:
    #include <Shobjidl.h>   //Earlier version
    
    IAppVisibility* pAppVis = NULL;
    HRESULT hr = CoCreateInstance(CLSID_AppVisibility, NULL, CLSCTX_INPROC_SERVER,
                          IID_IAppVisibility, (void**) &pAppVis);
    Results in a set of errors:

    Code:
    error C2065: 'IAppVisibility' : undeclared identifier
    error C2065: 'IID_IAppVisibility' : undeclared identifier
    Any idea how to define them?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: How to determine if a Metro app is currently displayed on the screen?

    Install the Win8 sdk and set the version (look inside the shobjidl.h file for the version).

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    831

    Re: How to determine if a Metro app is currently displayed on the screen?

    Quote Originally Posted by Arjay View Post
    Install the Win8 sdk and set the version (look inside the shobjidl.h file for the version).
    I'm not sure if Windows 8 SDK is compatible with Visual Studio 2008.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: How to determine if a Metro app is currently displayed on the screen?

    Quote Originally Posted by dc_2000 View Post
    I'm not sure if Windows 8 SDK is compatible with Visual Studio 2008.
    It may not be. In that case, look in the header file and grab the values you need.

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    831

    Re: How to determine if a Metro app is currently displayed on the screen?

    You know I'm not sure I understand those interface declarations really well.

    So I got this stuff out of the SDK, that I added to the .cpp file in my project:

    Code:
    EXTERN_C const CLSID CLSID_AppVisibility;
    
    class DECLSPEC_UUID("7E5FE3D9-985F-4908-91F9-EE19F9FD1514")
    AppVisibility;
    
    
    typedef /* [v1_enum] */ 
    enum MONITOR_APP_VISIBILITY
        {
            MAV_UNKNOWN	= 0,
            MAV_NO_APP_VISIBLE	= 1,
            MAV_APP_VISIBLE	= 2
        } 	MONITOR_APP_VISIBILITY;
    
    
    EXTERN_C const IID IID_IAppVisibilityEvents;
    
        
    MIDL_INTERFACE("6584CE6B-7D82-49C2-89C9-C6BC02BA8C38")
    IAppVisibilityEvents : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AppVisibilityOnMonitorChanged( 
            /* [in] */ __RPC__in HMONITOR hMonitor,
            /* [in] */ MONITOR_APP_VISIBILITY previousMode,
            /* [in] */ MONITOR_APP_VISIBILITY currentMode) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE LauncherVisibilityChange( 
            /* [in] */ BOOL currentVisibleState) = 0;
        
    };
    
    
    
    EXTERN_C const IID IID_IAppVisibility;
    
    MIDL_INTERFACE("2246EA2D-CAEA-4444-A3C4-6DE827E44313")
    IAppVisibility : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetAppVisibilityOnMonitor( 
            /* [in] */ __RPC__in HMONITOR hMonitor,
            /* [out] */ __RPC__out MONITOR_APP_VISIBILITY *pMode) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE IsLauncherVisible( 
            /* [out] */ __RPC__out BOOL *pfVisible) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Advise( 
            /* [in] */ __RPC__in_opt IAppVisibilityEvents *pCallback,
            /* [out] */ __RPC__out DWORD *pdwCookie) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Unadvise( 
            /* [in] */ DWORD dwCookie) = 0;
        
    };
    It compiles, but now the linker can't find their definitions:

    error LNK2001: unresolved external symbol _CLSID_AppVisibility
    error LNK2001: unresolved external symbol _IID_IAppVisibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center