Search code examples
vb.netonclickdisabled-controlaxwindowsmediaplayer

VB.net Disable-Deactivate Left Click Handle-Event-Function On AxWindowsMediaPlayer


Whenever my AxWindowsMediaPlayer1 is on fullscreen and I click on it, it basically either stops my player or starts playing again from the moment it was paused. Is there anyway to disable touch/click on my player forever?

I should probably mention that I've already added this:

AxWindowsMediaPlayer1.enableContextMenu = False
AxWindowsMediaPlayer1.Ctlenabled = False

The first one disables the option menu which appears when you right click on the media player and the second one disables main functions such as double clicking it to go fullscreen but none of those two solves my little problem.


EDIT: I still haven't find a way to solve this pfff. If anyone can help me, then feel free and post about it. Is there maybe any possible way to disable the play-pause button function forever?


Solution

  • AddHandler mpOCX.MouseMoveEvent, AddressOf doMouseMove
    
    Private Sub doMouseMove(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MouseMoveEvent)
        OnMouseMove(New MouseEventArgs(MouseButtons.None, 0, e.fX, e.fY, 0))
    End Sub
    
    ' ... not sure if these will have some effect
    
    mpOCX.uiMode = "none"
    mpOCX.Ctrlenabled = False
    mpOCX.enableContextMenu = False
    mpOCX.stretchToFit = True ' bonus
    
    ' ... to change the mouse cursor, override OnMouseEnter in your mpOCX object, which inherits from AxWindowsMediaPlayer:
    
    Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
        ' ... again, this goes in the 
        Cursor = Cursors.Arrow
        MyBase.OnMouseEnter(e)
    End Sub
    
    ' ... also, to short-circuit keyboard messages, you will have to Override PreProcessMessage in the mpOCX class, so might as well make one.
    ' ... these fire for keydown for WMP shortcut keys, keyup for all regular keys, but they don't fire keyup for WMP shortcut keys. this WILL disable all navigation via keyboard in WMP, so you can't press ctrl+O for example.
    
    Public Overrides Function PreProcessMessage(ByRef m As Message) As Boolean
        Return True
        'Return MyBase.PreProcessMessage(m) ' do not uncomment
    End Function
    
    ' ... other methods you could Override instead are ProcessCmdKey, ProcessDialogChar, ProcessDialogKey, ProcessKeyMessage, ProcessKeyEventArgs, ProcessKeyMessage, ProcessKeyPreview, ProcessMnemonic - but it's like playing whack-a-mole...
    

    Oh sorry, I misread your question, lol ;p In fact, I can't even remember if this disables mouse clicks or not.. it looks like it does, its in my WMP code, but I'd have to fix some lines and rebuild ;p so I can't test at the moment, but I hope it helps.

    Actually, there is a MouseDownEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MouseDownEvent) which should allow you to handle that in the same manner. I'm not sure what my mousemove code is for, but it does something, I can guarantee that. Probably just fires events to move the cursor, since the messages are being sent to the control.