473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Drag images from IE to vb.net application

I am creating an application to categorize images from websites. I
have tried a few sets of sample code to try to copy the image when it
is dropped into my vb.net application but it seem that the dragdrop
event never fires. I have enabled the AllowDrop. Does anyone have
any sample code or suggestion?

Thanks,

William
Nov 20 '05 #1
2 5295
Hi,

Set the picturebox1.allowdrop=true. This should allow to
drag an image from a webpage to the picturebox.
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then

Dim strFile() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

Dim fi As New System.IO.FileInfo(strFile(0))

If fi.Extension = ".gif" Or fi.Extension = ".bmp" Or _

fi.Extension = ".jpg" Or fi.Extension = ".jpeg" Then

e.Effect = DragDropEffects.Copy

End If

End If

End Sub

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

Dim s() As String = CType(e.Data.GetData(DataFormats.FileDrop), String())

Dim fs As New System.IO.FileStream(s(0), IO.FileMode.Open)

Dim bm As New Bitmap(fs)

fs.Close()

PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

PictureBox1.Image = bm

End Sub

Ken

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

"William" <bk******@hotmail.com> wrote in message
news:e0**************************@posting.google.c om...
I am creating an application to categorize images from websites. I
have tried a few sets of sample code to try to copy the image when it
is dropped into my vb.net application but it seem that the dragdrop
event never fires. I have enabled the AllowDrop. Does anyone have
any sample code or suggestion?

Thanks,

William
Nov 20 '05 #2
Thanks Ken,

This code works good, it does not work with images with links
associated to them it there a way around this. Please let me know
Thanks,

William


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:<uz**************@TK2MSFTNGP09.phx.gbl>...
Hi,

Set the picturebox1.allowdrop=true. This should allow to
drag an image from a webpage to the picturebox.
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then

Dim strFile() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

Dim fi As New System.IO.FileInfo(strFile(0))

If fi.Extension = ".gif" Or fi.Extension = ".bmp" Or _

fi.Extension = ".jpg" Or fi.Extension = ".jpeg" Then

e.Effect = DragDropEffects.Copy

End If

End If

End Sub

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

Dim s() As String = CType(e.Data.GetData(DataFormats.FileDrop), String())

Dim fs As New System.IO.FileStream(s(0), IO.FileMode.Open)

Dim bm As New Bitmap(fs)

fs.Close()

PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

PictureBox1.Image = bm

End Sub

Ken

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

"William" <bk******@hotmail.com> wrote in message
news:e0**************************@posting.google.c om...
I am creating an application to categorize images from websites. I
have tried a few sets of sample code to try to copy the image when it
is dropped into my vb.net application but it seem that the dragdrop
event never fires. I have enabled the AllowDrop. Does anyone have
any sample code or suggestion?

Thanks,

William

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: portraitmaker | last post by:
I found some drag and drop code on the web and modified it a little b taking out some of the stuff I didn't need. This sample allows you to drag an image in a table to another positio and swaps...
6
by: Colin Young | last post by:
I've got a owner-drawn listview control that displays images and now I'm trying to implement drag and drop so I can drag images from the control and drop them onto other applications. So far if I...
4
by: Dave | last post by:
I need to add the ability to drag from a Windows Form and drop into a non dotNet application. For example, having a generated image in my app that I wish to drag out into explorer as a friendly way...
3
by: Joe Turek | last post by:
I store images in a database instead of the filesystem. I deliver these images via a page that uses Response.OutputStream to send the bytes back to a calling page. So a given page on my site will...
1
by: Robin Tucker | last post by:
Apologies for the ambiguous title, you will be expecting me to be asking how to perform drag and drop from my application into another application. Well, kind-of. I've got drag and drop sorted,...
1
by: Riyaz | last post by:
Hi mates, Im developing an purely client side drag & drop application with JavaScript. I got a code for IE 4.0 and Netscape 4.0... while trying to update code to work in modern browsers like IE...
2
by: sebastian.janoschka | last post by:
Hi, I build my first Drag & Drop with JavaScript and I would like to drag the pictures when I click on it. When I create a normal div tag with some text the script works, but when I put a...
0
by: arvinds | last post by:
I have an application in which I have 2 forms. 1.Review Form 2. FilmForm. Review Form is used for Loading some images and we can transfer the Images from Review From to FilmForm by Drag-Drop...
0
by: jgraham | last post by:
I am trying to figure out how to receive images that are dropped from a web browser (IE or Firefox). For instance, after performing an image search on Google, I have several thumbnails displayed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.