2

I have ax windows media player in my windows forms application. When the user double clicks on it, it becomes full screen.

PROBLEM: I want the user to be able to go back to normal screen when he presses the "escape key". I have put a keydown event on the ax media player. This key down event works when in normal mode, but fails when the media player is made full screen.

 WMPLarge.KeyDownEvent += new AxWMPLib._WMPOCXEvents_KeyDownEventHandler(Form1_KeyDown);

 private void Form1_KeyDown(object sender, AxWMPLib._WMPOCXEvents_KeyDownEvent e)
    {
        if (e.nKeyCode == 27)
        {
            MessageBox.Show("");
            WMPLarge.fullScreen = false;
            WMPSmall.fullScreen = false;
        }
    }

How can I achieve this ?

Akash Deshpande
  • 2,583
  • 10
  • 41
  • 82

1 Answers1

3

Here is one code snippet I used, I hope that helps.

public partial class Form16 : Form,IMessageFilter
{
    public Form16()
    {
        InitializeComponent();
    }

    private void Form16_Load(object sender, EventArgs e)
    {
        this.axWindowsMediaPlayer1.URL = @"D:\MyVideo\myfile.wmv";
        Application.AddMessageFilter(this);
    }

    private void Form16_FormClosing(object sender, FormClosingEventArgs e)
    {
        Application.RemoveMessageFilter(this);
    }

    #region IMessageFilter Members
    private const UInt32 WM_KEYDOWN = 0x0100;
    public bool PreFilterMessage(ref Message m)
    {
        if (m.Msg == WM_KEYDOWN)
        {
            Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
            if (keyCode == Keys.Escape)
            {
                this.axWindowsMediaPlayer1.fullScreen = false;
            }
            return true;
        }
        return false;
    }
    #endregion
}
user781700
  • 844
  • 3
  • 15
  • 27