private int ToggleFullScreen()
{
int hr = 0;
OABool lMode;
// Don't bother with full-screen for audio-only files
if ((this.isAudioOnly) || (this.videoWindow == null))
return 0;
// Read current state
hr = this.videoWindow.get_FullScreenMode(out lMode);
DsError.ThrowExceptionForHR(hr);
if (lMode == OABool.False)
{
this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
// Save current message drain
hr = this.videoWindow.get_MessageDrain(out hDrain);
DsError.ThrowExceptionForHR(hr);
// Set message drain to application main window
hr = this.videoWindow.put_MessageDrain(this.Videopanel.Handle);
DsError.ThrowExceptionForHR(hr);
// Switch to full-screen mode
lMode = OABool.True;
hr = this.videoWindow.put_FullScreenMode(lMode);
videoWindow.put_AutoShow(OABool.False);
DsError.ThrowExceptionForHR(hr);
}
else
{
// Switch back to windowed mode
lMode = OABool.False;
hr = this.videoWindow.put_FullScreenMode(lMode);
DsError.ThrowExceptionForHR(hr);
// Undo change of message drain
hr = this.videoWindow.put_MessageDrain(hDrain);
DsError.ThrowExceptionForHR(hr);
// Reset video window
hr = this.videoWindow.SetWindowForeground(OABool.True);
DsError.ThrowExceptionForHR(hr);
// Reclaim keyboard focus for player application
//this.Focus();
}
return hr;
}