6 Replies - 1557 Views - Last Post: 15 December 2012 - 04:01 PM Rate Topic: -----

#1 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 195
  • Joined: 10-March 12

Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 01:00 PM

i have a form which contains a AxShockwaveFlash control. I need to make that control draggable, so i used this code:

    Private IsFormBeingDragged As Boolean = False
    Private MouseDownX As Integer
    Private MouseDownY As Integer


    Private Sub AxShockwaveFlash1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AxShockwaveFlash1.MouseDown
        If CustomizeMode = True Then
            If e.Button = MouseButtons.Left Then
                IsFormBeingDragged = True
                MouseDownX = e.X
                MouseDownY = e.Y
            End If
        End If
    End Sub

    Private Sub AxShockwaveFlash1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AxShockwaveFlash1.MouseMove
        If CustomizeMode = True Then
            If IsFormBeingDragged Then
                Dim temp As Point = New Point()
                temp.X = AxShockwaveFlash1.Location.X + (e.X - MouseDownX)
                temp.Y = AxShockwaveFlash1.Location.Y + (e.Y - MouseDownY)
                AxShockwaveFlash1.Location = temp
                temp = Nothing
            End If
        End If
    End Sub
    
    

    Private Sub AxShockwaveFlash1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AxShockwaveFlash1.MouseUp
        If CustomizeMode = True Then
            If e.Button = MouseButtons.Left Then
                IsFormBeingDragged = False
                regKey.SetValue("POSITION_AxShockwaveFlash1", AxShockwaveFlash1.Location.X & "," & AxShockwaveFlash1.Location.Y)
            End If
        End If
    End Sub



The above code works for any control. But when i am trying to add it for the flash control, if it try to compile the program, i get the following error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Event MouseUp is not valid on this ActiveX control.".
How could i go around this limitation?
Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: Event MouseUp is not valid on this ActiveX control

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,060
  • Joined: 02-July 08

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 01:29 PM

Have you explored the object to see if there is an event that is close to the mouseUp - maybe it is a diff name?
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,060
  • Joined: 02-July 08

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 02:10 PM

Put the activex object inside a panel and move the panel. You may have to use the form's mouse events for triggers since the panel will be covered by an object.
Was This Post Helpful? 1
  • +
  • -

#4 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 195
  • Joined: 10-March 12

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 02:12 PM

i did, and there is no event that could replace the one i need. I was just thinking to inherit flash object and create a new control with custom events added. I added a reference to Shockwave Flash COM dll and imported the namespace, but i can't seem to find a way to inherit that class.

my form already has a different drag code in its mouse events, i need to be able to move the form and its controls independently one from another.
Was This Post Helpful? 0
  • +
  • -

#5 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 195
  • Joined: 10-March 12

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 02:23 PM

i tried this:

Inherits ShockwaveFlashObjects.ShockwaveFlash



and it says "class can inherit only from other class"

When i hover with the mouse over the word ShockwaveFlash from the line

WithEvents _FlashMovie As New ShockwaveFlashObjects.ShockwaveFlash



it says "interface ShockwaveFlash", so i guess that is because it is an activex object and not a windows form control? i'm quite confused. I will try inheriting Windows.Forms.Control and add the flash as an object.
Was This Post Helpful? 0
  • +
  • -

#6 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 195
  • Joined: 10-March 12

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 03:04 PM

This is what i came up with in the end:

    Public Class FlashMovieControl
        Inherits Windows.Forms.Control
        WithEvents _FlashMovie As New AxShockwaveFlashObjects.AxShockwaveFlash()
 
        Public Sub New()
            MyBase.New()
            InitializeComponent()
            With _FlashMovie
                .Dock = System.Windows.Forms.DockStyle.Fill
                .Enabled = True
                .Location = New System.Drawing.Point(125, 52)
                .Name = "FlashMovieControl1"
                .Size = New System.Drawing.Size(672, 111)
            End With
           
            Me.Controls.Add(_FlashMovie)
        End Sub

        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.SuspendLayout()
            Me.Name = "FlashMovieControl"
            Me.Size = New System.Drawing.Size(100, 50)
            Me.ResumeLayout(False)
        End Sub
    End Class



The above custom control has all the mouse events, but now it seems i have problems exposing the public properties of the flash movie object. I need to add properties for setting the movie scale, the movie path etc.

I tried implementing it this way:

        <DefaultValue("ExactFit")> _
        Public Property CtlScale() As String
            Get
                Return _FlashMovie.CtlScale
            End Get
            Set(ByVal value As String)
                _FlashMovie.CtlScale = value
            End Set
        End Property


and it compiles fine into a dll. But when i try to add the custom control to a form, it says "Failed to create component FlashMovieControl. The error message follows: 'Property get of 'CtlScale' cannot be invoked at this time.' Am i doing something wrong?
Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,060
  • Joined: 02-July 08

Re: Event MouseUp is not valid on this ActiveX control

Posted 15 December 2012 - 04:01 PM

If you don't declare the object as Public or Friend Withevent... then it is considered Private and that is why you cannot see the object outside of this class you built.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1