how to detect if window media player is running in full screen mode
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: how to detect if window media player is running in full screen mode

  1. #1
    Join Date
    Jan 2013
    Posts
    4

    Post how to detect if window media player is running in full screen mode

    How can I check if window media player is running in full screen mode & topmost in c++ MFC?
    What I used is this logic:
    I compared media player full screen coordinates to that of monitor coordinates.If they are same implies media player is in fullscreen.But it has one flaw.Whenever there are control(for play,pause) displayed in full screen in media player, coordinates are not coming same as that of monitor.

    Need any other logic to implement this.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,976

    Re: how to detect if window media player is running in full screen mode

    Code:
    [
      odl,
      uuid(6C497D62-8919-413C-82DB-E935FB3EC584),
      helpstring("IWMPPlayer4: Public interface."),
      dual,
      oleautomation
    ]
    interface IWMPPlayer4 : IWMPCore3 {
        [id(0x00000013), propget, helpstring("Returns a boolean value specifying whether or not the control is enabled")]
        HRESULT enabled([out, retval] VARIANT_BOOL* pbEnabled);
        [id(0x00000013), propput, helpstring("Returns a boolean value specifying whether or not the control is enabled")]
        HRESULT enabled([in] VARIANT_BOOL pbEnabled);
        [id(0x00000015), propget, helpstring("Returns a boolean value specifying whether or not the control is in full screen mode")]
        HRESULT fullScreen([out, retval] VARIANT_BOOL* pbFullScreen);
        [id(0x00000015), propput, helpstring("Returns a boolean value specifying whether or not the control is in full screen mode")]
        HRESULT fullScreen(VARIANT_BOOL pbFullScreen);
        [id(0x00000016), propget, helpstring("Returns a boolean value specifying whether or not the context menu is enabled on the control")]
        HRESULT enableContextMenu([out, retval] VARIANT_BOOL* pbEnableContextMenu);
        [id(0x00000016), propput, helpstring("Returns a boolean value specifying whether or not the context menu is enabled on the control")]
        HRESULT enableContextMenu(VARIANT_BOOL pbEnableContextMenu);
        [id(0x00000017), propput, helpstring("Specifies the ui mode to select")]
        HRESULT uiMode([in] BSTR pbstrMode);
        [id(0x00000017), propget, helpstring("Specifies the ui mode to select")]
        HRESULT uiMode([out, retval] BSTR* pbstrMode);
        [id(0x00000018), propget, helpstring("Returns a boolean value specifying whether or not video is stretched")]
        HRESULT stretchToFit([out, retval] VARIANT_BOOL* pbEnabled);
        [id(0x00000018), propput, helpstring("Returns a boolean value specifying whether or not video is stretched")]
        HRESULT stretchToFit([in] VARIANT_BOOL pbEnabled);
        [id(0x00000019), propget, helpstring("Returns a boolean value specifying whether or not video is windowless")]
        HRESULT windowlessVideo([out, retval] VARIANT_BOOL* pbEnabled);
        [id(0x00000019), propput, helpstring("Returns a boolean value specifying whether or not video is windowless")]
        HRESULT windowlessVideo([in] VARIANT_BOOL pbEnabled);
        [id(0x0000001a), propget, helpstring("Indicates whether the player is running remotely")]
        HRESULT isRemote([out, retval] VARIANT_BOOL* pvarfIsRemote);
        [id(0x0000001b), propget, helpstring("Returns the player application handler")]
        HRESULT playerApplication([out, retval] IWMPPlayerApplication** ppIWMPPlayerApplication);
        [id(0x0000001c), helpstring("Opens the player with the specified URL")]
        HRESULT openPlayer([in] BSTR bstrURL);
    };
    Best regards,
    Igor

  3. #3
    Join Date
    Jan 2013
    Posts
    4

    Re: how to detect if window media player is running in full screen mode

    Need a C++ code to implement this logic.

  4. #4
    Join Date
    Jan 2013
    Posts
    4

    Re: how to detect if window media player is running in full screen mode

    Hi igor

    can you add some explanation to your solution suggested.
    I need a c++ code to implement that logic.

    Regards,
    Nitii

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,976

    Re: how to detect if window media player is running in full screen mode

    First of all, it's not clear from your OP whether the WMP is created by your app as WMPPlayer object, or you're talking about standalone WMP app running on the desktop.

    My guess is you create WMP player object programmatically, so you can inspect the object property fullScreen. To give you "a c++ code" I need to know details how the WMP object was created, as well as how you access it at runtime. Code snippet would be very useful, first of all for you.
    Best regards,
    Igor

  6. #6
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,378

    Re: how to detect if window media player is running in full screen mode

    What about the CWnd::GetWindowPlacement method? If CWnd is maximized, the showCmd member of WINDOWPLACEMENT is SW_SHOWMAXIMIZED.

  7. #7
    Join Date
    Jan 2013
    Posts
    4

    Re: how to detect if window media player is running in full screen mode

    Hi igor,

    The application I am working on is a MFC standalone application. Not using a IWMPlayer object etc. 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

    testFullScreenApp()
    {
    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.rcClient.top == wi.rcWindow.top && wi.rcWindow.top== deskRect.top) &&
    ((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.
    Last edited by nitii; January 24th, 2013 at 12:25 AM.

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,976

    Re: how to detect if window media player is running in full screen mode

    Not using a IWMPlayer object
    Sorry I can not help you with this. Fullscreen window is not obliged to be flagged maximized, BTW.
    Best regards,
    Igor

  9. #9
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,378

    Re: how to detect if window media player is running in full screen mode

    As you have a handle to the required window, what about using ::GetWindowPlacement such as

    Code:
    WINDOWPLACEMENT  wp = {0};
    wp.length = sizeof(WINDOWPLACEMENT);
    if (::GetWindowPlacement(hForeGndWnd, &wp)) {
          if (wp.showCmnd == SW_SHOWMAXIMIZED) {
             return TRUE;
          }
    }

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: how to detect if window media player is running in full screen mode

    Quote Originally Posted by 2kaud View Post
    As you have a handle to the required window, what about using ::GetWindowPlacement such as

    Code:
    WINDOWPLACEMENT  wp = {0};
    wp.length = sizeof(WINDOWPLACEMENT);
    if (::GetWindowPlacement(hForeGndWnd, &wp)) {
          if (wp.showCmnd == SW_SHOWMAXIMIZED) {
             return TRUE;
          }
    }
    As Igor Vartanov already wrote:

    Quote Originally Posted by Igor Vartanov View Post
    Sorry I can not help you with this. Fullscreen window is not obliged to be flagged maximized, BTW.
    Victor Nijegorodov

  11. #11
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,378

    Re: how to detect if window media player is running in full screen mode

    If GetWindowPlacement is not of help, what are the co-ordinates being returned when media player is full screen but control for play, pause etc is displayed? You will probably need to determine if foreground window is media player (from screen title) and then have seperate check for these co-ordinates.

    Why do you need to know if full screen - what does your program do with the info? If media player window, you could maximise it and then return TRUE.

    Code:
    ::ShowWindow(hForeGndWnd, SW_SHOWMAXIMIZED);

Tags for this Thread

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