Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. WebBrowser Drag and Drop

WebBrowser Drag and Drop

Scheduled Pinned Locked Moved Visual Basic
csharpvisual-studioquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StuBaum
    wrote on last edited by
    #1

    Hi All, Has anybody been successful with drag and drop or pasting to a webbrowser control in VS 9.0 VB.net? All examples I have come across refer to ‘ExecWB’ which unfortunatly is not a member of System.windows.forms.webbrowser in VB.Net 9.0. There is a property ‘AllowWebBrowserDrop’ but how I trap the event when DragDrop, DragEnter, ect… events for the control don’t exist? I am not sure where to trap the drop event. I would gladly give you my firstborn for any relevant information on the subject. Thanks Stu

    S 1 Reply Last reply
    0
    • S StuBaum

      Hi All, Has anybody been successful with drag and drop or pasting to a webbrowser control in VS 9.0 VB.net? All examples I have come across refer to ‘ExecWB’ which unfortunatly is not a member of System.windows.forms.webbrowser in VB.Net 9.0. There is a property ‘AllowWebBrowserDrop’ but how I trap the event when DragDrop, DragEnter, ect… events for the control don’t exist? I am not sure where to trap the drop event. I would gladly give you my firstborn for any relevant information on the subject. Thanks Stu

      S Offline
      S Offline
      StuBaum
      wrote on last edited by
      #2

      Well... Nobody has answered my question so let me explain how I overcame the webbrowsers controls drag and drop issues. I created a transparent control (TCtl) that I placed over the webbrowser control I added handlers for dragenter and dragdrop for TCtl. I parsed the dropped html info to retrieve all of the images url's & then downloaded the images to a localdrive & replaced the href in the html to point to the local images. I then saved the html to a file. I could then load the file into the webbrowser control. Slicker than a rats ass if I may say so. Some of the code is shown below. For saving the images.... Source = web url, Dest = local drive.... Private Sub GetWebFile(ByVal strSource As String, ByVal strDest As String) Dim WebConnection As New WebClient() Try If File.Exists(strDest) Then File.Delete(strDest) WebConnection.DownloadFile(strSource, strDest) Catch ex As Exception MsgBox("Error retrieving web file", ex.Message) End Try End Sub For the drag and drop from a webpage (not complete).... Private Sub TCtlDragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) e.Effect = DragDropEffects.Copy If e.Data.GetDataPresent(DataFormats.Html) Then TCtlDropFormat = "HTML" ElseIf e.Data.GetDataPresent(DataFormats.FileDrop) Then TCtlDropFormat = "File" ElseIf e.Data.GetDataPresent(DataFormats.Bitmap) Then TCtlDropFormat = "Bitmap" ElseIf e.Data.GetDataPresent(DataFormats.Text) Then TCtlDropFormat = "Text" Else e.Effect = DragDropEffects.None End If End Sub Private Sub TCtlDragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Select Case TCtlDropFormat Case "HTML" Dim strData As String = e.Data.GetData(DataFormats.Html) DoHTMLDrop(strData) Case "File" Stop Case "Bitmap" Stop Case "Text" Stop End Select End Sub For the transparent control.... Public DWBSTCtl As New TransparentCtl DWBSTCtl.Left = 0 DWBSTCtl.Top = 0 DWBSTCtl.Width = wbData.Width - 20 DWBSTCtl.Height = wbData.Height DWBSTCtl.AllowDrop = True AddHandler DWBSTCtl.DragEnter, AddressOf TCtlDragEnter AddHandler DWBSTCtl.DragDrop, AddressO

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups