1

I'm trying to design a "pass-through" for the axShockwaveFlash control. This control does not have .MouseDown, .MouseUp or .MouseMove events associated with it. Sadly, I need to detect these events on any shockwave controls as they are used in another class (which detects these events on a variety of different controls).

So, I tried designing a custom class, modifying the axShockwaveFlash class to include these events. However, I get the following error:

"Derived classes cannot raise base class events."

on the line:

RaiseEvent MouseDown(Me, EventArgs.Empty)

Full code (minus the up and move functions):

Imports System.Runtime.InteropServices
Imports System.Threading

Public Class MousedFlash

    Inherits AxShockwaveFlashObjects.AxShockwaveFlash

    'WndProc Inputs:
    Private Const WM_RBUTTONDOWN As Integer = &H204
    Private Const WM_LBUTTONDOWN As Integer = &H201

    Protected Overloads Sub OnMouseDown()
        RaiseEvent MouseDown(Me, EventArgs.Empty)
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            Case WM_RBUTTONDOWN
                Debug.WriteLine("MOUSE FLASH - right down!")
                Call OnMouseDown()
                Return
            Case WM_LBUTTONDOWN
                Debug.WriteLine("MOUSE FLASH - left down!")
                Call OnMouseDown()
                Return
        End Select
        MyBase.WndProc(m)
    End Sub

End Class

I think the Base Class is AxShockwaveFlashObjects - but I can't see the mouse events defined in here. Bit out my depth on this one - any help appreciated.

T.S.
  • 18,195
  • 11
  • 58
  • 78
stigzler
  • 793
  • 2
  • 12
  • 29

2 Answers2

2

Having a look at this page it looks like instead of trying to raise the base class event, you should call the Sub which handles that event directly. So try replacing

Protected Overloads Sub OnMouseDown()
    RaiseEvent MouseDown(Me, EventArgs.Empty)
End Sub

with

Protected Overloads Sub OnMouseDown()
    MyBase.MouseDown(Me, EventArgs.Empty)
End Sub
5uperdan
  • 1,481
  • 2
  • 14
  • 30
0

Thanks. In the end a mixture of carelessness on my part and the wrong type of over-ride. Final working replacement:

Shadows Event MouseDown As System.EventHandler
Protected Overridable Sub OnMouseDownTrigger()
    RaiseEvent MouseDown(Me, EventArgs.Empty)
End Sub
stigzler
  • 793
  • 2
  • 12
  • 29
  • 2
    Be careful with that. Marking something as `Shadows` is rarely the correct thing to do. I'n my 10 years or so of .NET experience, I think I've used it maybe twice. Be sure you understand exactly what it does by reading this https://msdn.microsoft.com/en-us/library/c4swkw24.aspx – Bradley Uffner Jul 16 '15 at 19:08