/// <summary> /// Full screen mode or un-do full screen mode. /// </summary> public void FullScreenMode() { int hr = 0; // Stop and reset postion to beginning if ((_currentState == PlayState.Paused) || (_currentState == PlayState.Running) || (_currentState == PlayState.Stopped)) { OABool mode; // Don't bother with full-screen for audio-only files if ((_isAudioOnly) || (_videoWindow == null)) { return; } // Read current state hr = _videoWindow.get_FullScreenMode(out mode); DsError.ThrowExceptionForHR(hr); if (mode == OABool.False) { // Save current message drain hr = _videoWindow.get_MessageDrain(out _pDrain); DsError.ThrowExceptionForHR(hr); // Set message drain to application main window hr = _videoWindow.put_MessageDrain(_playWindow.Handle); DsError.ThrowExceptionForHR(hr); // Switch to full-screen mode mode = OABool.True; hr = _videoWindow.put_FullScreenMode(mode); DsError.ThrowExceptionForHR(hr); _isFullScreen = true; } else { // Switch back to windowed mode mode = OABool.False; hr = _videoWindow.put_FullScreenMode(mode); DsError.ThrowExceptionForHR(hr); // Undo change of message drain hr = _videoWindow.put_MessageDrain(_pDrain); DsError.ThrowExceptionForHR(hr); // Reset video window hr = _videoWindow.SetWindowForeground(OABool.True); DsError.ThrowExceptionForHR(hr); // Reclaim keyboard focus for player application //this.Focus(); _isFullScreen = false; } } }
//////////////// /// Get/Put FullScreenMode private void TestFullScreenMode() { int hr; OABool FullScreenMode1, FullScreenMode2; // Read the current value hr = m_ivw.get_FullScreenMode(out FullScreenMode1); Marshal.ThrowExceptionForHR(hr); // Change it hr = m_ivw.put_FullScreenMode(~FullScreenMode1); Marshal.ThrowExceptionForHR(hr); // Re-read hr = m_ivw.get_FullScreenMode(out FullScreenMode2); Marshal.ThrowExceptionForHR(hr); // Make sure the value we set is what we just read Debug.Assert(FullScreenMode1 != FullScreenMode2, "Put/Get FullScreenMode"); // Try it the other way // Read the current value hr = m_ivw.get_FullScreenMode(out FullScreenMode1); Marshal.ThrowExceptionForHR(hr); // Change it hr = m_ivw.put_FullScreenMode(~FullScreenMode1); Marshal.ThrowExceptionForHR(hr); // Re-read hr = m_ivw.get_FullScreenMode(out FullScreenMode2); Marshal.ThrowExceptionForHR(hr); // Make sure the value we set is what we just read Debug.Assert(FullScreenMode1 != FullScreenMode2, "Put/Get FullScreenMode"); }