locked
Flash Player Drag and Drop

    Question

  • Hi, I started this on another thread but, I stopped getting responses so to get an answer I'm making a new one. I am making a standalone flash player and all I need is the Drag and Drop function, I have something that I extracted from a drag and drop with a picture box but I need help formatting it to work with a flash player. Here is the code for the drag and drop so far:

     

      Private Sub AxShockwaveFlash1_DragDrop(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxShockwaveFlash1.DragDrop
        Try
          AxShockwaveFlash1.Movie = Mov.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
        Catch ex As Exception
          MessageBox.Show("Error Doing Drag/Drop")
        End Try
      End Sub

     

    The places where I'm having problems are, first where it says Mov.fromfile, and that is where it said image.fromfile, but I can't find something to work with the AxShcokwaveFlash. Second place where it says e.Data it gives me an error saying

    "'Data' is not a member of 'System.EventArgs'".

     

    Please help, Thanks in advanced!

    Thursday, January 27, 2011 3:06 AM

Answers

  • Hi ComputerSolutionsinc,

     

    Sorry for the delay.

    How about the issue on your side? I find there are no DragEnter and DragDrop event in shockwave flash control.

    So I add my Shockwave Flash control into panel control.

     

    Code snippet:

     

     

    Imports System.IO

    Public Class Form1

        Dim validData As Boolean

        Dim flashFile As String

     

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Panel1.AllowDrop = True

            Panel1.Controls.Add(AxShockwaveFlash1)

        End Sub

        Protected Function GetFilename(ByRef filename As String, ByVal e As DragEventArgs) As Boolean

            Dim ret As Boolean = False

            filename = String.Empty

            If ((e.AllowedEffect And DragDropEffects.Copy) _

                        = DragDropEffects.Copy) Then

                Dim data As Array = CType(CType(e.Data, IDataObject).GetData("FileDrop"), Array)

                If (Not (data) Is Nothing) Then

                    If ((data.Length = 1) _

                                AndAlso (TypeOf data.GetValue(0) Is String)) Then

                        filename = CType(data, String())(0)

                        Dim ext As String = Path.GetExtension(filename).ToLower

                        If (ext = ".swf") Then

                            ret = True

                            flashFile = filename

                        End If

                    End If

                End If

            End If

            Return ret

        End Function

     

        Private Sub Panel1_DragEnter_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter

            Dim filename As String

            validData = GetFilename(filename, e)

            If validData Then

                e.Effect = DragDropEffects.Copy

            Else

                e.Effect = DragDropEffects.None

            End If

        End Sub

     

        Private Sub Panel1_DragDrop_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop

            If validData Then

                Me.AxShockwaveFlash1.Movie = flashFile

            End If

        End Sub

    End Class

     

    In addition, you can consider using Microsoft Web Browser control to play your flash file, which has its own drag and drop feature.  You don’t need pay further effort to implement it by yourself.

     

    You can check this thread for how to use Microsoft Web Browser control:

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/499257a8-d997-49ff-99b1-400524a0c19e

     

    I hope this will helpful, and I look forward to hearing from you soon.

     

    Best Regards,


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 01, 2011 10:44 AM
    Moderator

All replies

  • Alright Update, Still have the second problem listed in the post above but I fixed the first one. Now I have a different problem first here's the new code:

      Private Sub AxShockwaveFlash1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles AxShockwaveFlash1.DragDrop
        Try
          AxShockwaveFlash1.Movie = Mov.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
        Catch ex As Exception
          MessageBox.Show("Error Doing Drag/Drop")
        End Try
      End Sub
      Private Sub AxShockwaveFlash1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles AxShockwaveFlash1.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
          e.Effect = DragDropEffects.Copy
        End If
      End Sub

    Now every time I try and debug the program an error comes up and says this, An error occurred creating the form.

    See Exception.InnerException for details. The error is: Event DragEnter is not valid on this ActiveX control.

    Please help, Thanks in advanced!

    Thursday, January 27, 2011 3:17 AM
  • Hi ComputerSolutionsinc,

     

    Thanks for your post.

     

    I am doing some research on your issue, and I’ll post my code as soon as possible.

     

    Before that, here is some similar case to which you can refer. The demo project can open the image file using drag and drop:

    A Simple Drag And Drop How To Example

     

    In addition, here is a document about Implementing Drag and Drop in Visual Basic .NET

     

    I hope this will helpful, and I look forward to hearing from you soon.

     

    Best Regards,


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 28, 2011 6:18 AM
    Moderator
  • Hi ComputerSolutionsinc,

     

    Sorry for the delay.

    How about the issue on your side? I find there are no DragEnter and DragDrop event in shockwave flash control.

    So I add my Shockwave Flash control into panel control.

     

    Code snippet:

     

     

    Imports System.IO

    Public Class Form1

        Dim validData As Boolean

        Dim flashFile As String

     

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Panel1.AllowDrop = True

            Panel1.Controls.Add(AxShockwaveFlash1)

        End Sub

        Protected Function GetFilename(ByRef filename As String, ByVal e As DragEventArgs) As Boolean

            Dim ret As Boolean = False

            filename = String.Empty

            If ((e.AllowedEffect And DragDropEffects.Copy) _

                        = DragDropEffects.Copy) Then

                Dim data As Array = CType(CType(e.Data, IDataObject).GetData("FileDrop"), Array)

                If (Not (data) Is Nothing) Then

                    If ((data.Length = 1) _

                                AndAlso (TypeOf data.GetValue(0) Is String)) Then

                        filename = CType(data, String())(0)

                        Dim ext As String = Path.GetExtension(filename).ToLower

                        If (ext = ".swf") Then

                            ret = True

                            flashFile = filename

                        End If

                    End If

                End If

            End If

            Return ret

        End Function

     

        Private Sub Panel1_DragEnter_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter

            Dim filename As String

            validData = GetFilename(filename, e)

            If validData Then

                e.Effect = DragDropEffects.Copy

            Else

                e.Effect = DragDropEffects.None

            End If

        End Sub

     

        Private Sub Panel1_DragDrop_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop

            If validData Then

                Me.AxShockwaveFlash1.Movie = flashFile

            End If

        End Sub

    End Class

     

    In addition, you can consider using Microsoft Web Browser control to play your flash file, which has its own drag and drop feature.  You don’t need pay further effort to implement it by yourself.

     

    You can check this thread for how to use Microsoft Web Browser control:

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/499257a8-d997-49ff-99b1-400524a0c19e

     

    I hope this will helpful, and I look forward to hearing from you soon.

     

    Best Regards,


    Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 01, 2011 10:44 AM
    Moderator
  • Hey, Thanks this helped me a lot! And I can't thank you enough but would you also know how to make it load files that you dragged onto the icon of the program on your desktop? If so I would be extremely happy.

     

    Thanks in advanced!

    Thursday, February 03, 2011 1:25 AM
  • Knock knock?? anyone home?
    Sunday, February 06, 2011 11:21 PM
  • Hello,

     

    Considering that many developers in this forum ask how to manipulate WebBrowser component (enabling flash, suppressing error messages, proxy support), rotate or flip images, my team has created a code sample for this frequently asked programming task in Microsoft All-In-One Code Framework. You can download the code samples at:

     

    VBWebBrowserWithProxy

     

    http://bit.ly/VBWebBrowserWithProxy

     

    CSWebBrowserWithProxy

     

    http://bit.ly/CSWebBrowserWithProxy

     

    With these code samples, we hope to reduce developers’ efforts in solving the frequently asked

    programming tasks. If you have any feedback or suggestions for the code samples, please email us: onecode@microsoft.com.

    ------------

    The Microsoft All-In-One Code Framework (http://1code.codeplex.com) is a free, centralized code sample library driven by developers' needs. Our goal is to provide typical code samples for all Microsoft development technologies, and reduce developers' efforts in solving typical programming tasks.

    Our team listens to developers’ pains in MSDN forums, social media and various developer communities. We write code samples based on developers’ frequently asked programming tasks, and allow developers to download them with a short code sample publishing cycle. Additionally, our team offers a free code sample request service. This service is a proactive way for our developer community to obtain code samples for certain programming tasks directly from Microsoft.

    Thanks

    Microsoft All-In-One Code Framework

    Friday, March 25, 2011 1:38 AM