[Resolved] How to Disable Double-Click and Right-Click in Windows Media Player Control in VB.NET

Visual Basic is an event-driven programming language which let it's users to create awesome software. For those who love programming and are creating a project like a Media Player may face the difficulty that most of the people are facing that is disabling the double-click control and right click control in windows media player in VB.NET. Here's I got the answer and that inspired me to write this post, so stick till the end of the post it's not the tough task only it needs a one line command.

Basic Problems Faced 

When Trying To Eliminate Double-Click Function Directly From MouseDoubleClick Event

 Private Sub AxWindowsMediaPlayer1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles wmp.MouseDoubleClick
        If AxWindowsMediaPlayer1.fullScreen Then
            AxWindowsMediaPlayer1.fullScreen = False
        End If
  End Sub
When you try to execute this code it expels the error which says "Event MouseDoubleClick is not valid on this ActiveX control".
By this error it is clear that you may not add a MouseDoubleClick or MouseClick events in the Windows media Player Control.

Disable-Double Click Function in Windows Media Player

When you double click on the windows media player control when it is playing a media file then the control redirects you to the full screen mode. So, how to disable that? Well there are two ways to do that.

Method 1 - Using Timer

  1. After adding Windows Media Player Control in your form add a timer tool from the toolbox.
  2. Move on to the Properties Window and change Enabled to True.
                   Or you may directly add code to the Form1_Load
  3. Double Click to the Timer1 Control and you will be redirected to the Code Window
  4. Now type the following code
  If AxWindowsMediaPlayer1.fullScreen Then
            AxWindowsMediaPlayer1.fullScreen = False
        End If
Now run your form you will find that every time you double click on the Windows Media Player Control nothing happens this means that the problem is resolved. And if you want to add custom functions when user Double Click on Windows Media Player Control then add you code just below the line 'AxWindowsMediaPlayer1.fullScreen = False'

Method 2 - Disable Double-Click and Right-Click Both

The following code lets you to disable Double-Click Function as well as any other functions like right click function also
AxWindowsMediaPlayer1.Ctlenabled = False
Note:- This code will disable all the mouse events like right click as well as the left click. And if you want to only disable double click function which makes it to run on full screen then you may try the above method i.e Method 1.

Post a Comment