I have webrowser in my project..Suppose i open google..I want to drag the google image,can somebody tell me how how to get the URL of the image,so dat i can download it from the net...

Recommended Answers

All 3 Replies

No need to use the URL as it will already be in your local browser cache.

Public Class FormDragDrop

	Private Sub FormDragDrop_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Me.AllowDrop = True
	End Sub

	Private Sub FormDragDrop_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
		If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
			e.Effect = DragDropEffects.Copy
		End If
	End Sub

	Private Sub FormDragDrop_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
		Dim handle As String() = e.Data.GetData(DataFormats.FileDrop, False)
		If (handle.Length > 0) Then
			If (System.IO.File.Exists(handle(0))) Then
				Me.BackgroundImage = Bitmap.FromFile(handle(0))
			End If
		End If
	End Sub
End Class

Obviously you will want to check the source and if multiple files are being dragged but this will let you drag the google image to the form and set it as the background.

hello sknake,first of all thx..but it not working for all the images..Suppose i go to google images link(upper) & if i drag dat image, its working..Now suppose i search taj Mahal in google images & if i drag any image from there,background is not changed..I want to drag all the images.....Plz tell me!!

Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("www.google.com")
        Me.AllowDrop = True
    End Sub

    Private Sub Form2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
            e.Effect = DragDropEffects.Copy
        End If
    End Sub



    Private Sub Form2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
        Dim handle As String() = e.Data.GetData(DataFormats.FileDrop, False)
        If (handle.Length > 0) Then
            If (System.IO.File.Exists(handle(0))) Then
                Me.BackgroundImage = Bitmap.FromFile(handle(0))
            End If
        End If
    End Sub
End Class

Give me a specific case where does this not work and you have also not modified the original code I posted. The original code has some limitations which i stated in the post:

Obviously you will want to check the source and if multiple files are being dragged

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.