VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,406 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,628 people online right now. Registration is fast and FREE... Join Now!




drag video from webbrowser

 

drag video from webbrowser, drag video from webbrowser and drop it to any control like button or a

ritu_latiyan

2 Jul, 2009 - 03:18 AM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 2

I tried it but not successful.please help me


CODE

Public Class Form1
    Dim WithEvents mydoc As System.Windows.Forms.HtmlDocument
    Dim mylink As System.Windows.Forms.HtmlElement
    Dim str As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("www.youtube.com")
    End Sub

    Private Sub Button1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button1.DragDrop
        Dim wb As WebBrowser
       wb = CType(sender, WebBrowser)
        str = getContent(mydoc.Url.AbsoluteUri.ToString)
(I dont know what to write in below line)
      'Button1.Image = e.Data.GetData(DataFormats.StringFormat)
    End Sub



    Private Sub Button1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button1.DragEnter
        Button1.AllowDrop = True
        e.Effect = e.AllowedEffect
         End Sub

    
  
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Try

            mydoc = WebBrowser1.Document
                      mydoc.AttachEventHandler("OnMouseDown", AddressOf mylink_MouseDown)

                           Catch ex As Exception
            MsgBox(ex.Message)
        End Try
         End Sub


    Private Sub mylink_MouseDown(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Dim wb As WebBrowser
            wb = CType(sender, WebBrowser)
            wb.DoDragDrop(wb.Document, DragDropEffects.Copy)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
    Private Function getContent(ByVal url As String) As String

        Dim buffer As String
        Try

                      Dim req As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
            req.AllowWriteStreamBuffering = True
        
                       Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
            Dim sr As StreamReader = New StreamReader(resp.GetResponseStream())
            buffer = sr.ReadToEnd()
            sr.Close()

        Catch exp As Exception

            buffer = "Error: " + exp.Message.ToString()
        End Try

        Return buffer
    End Function
  
End Class



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:48PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month