Dragging and Dropping
Dragging and Dropping
Dragging and Dropping
Dragging and Dropping
Dragging and Dropping
Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping
Dragging and Dropping Dragging and Dropping
Dragging and Dropping
Go Back  Xtreme Visual Basic Talk > > > Dragging and Dropping


Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2002, 03:58 AM
adrianosmond's Avatar
adrianosmond adrianosmond is offline
Freshman
 
Join Date: Nov 2002
Location: UK
Posts: 48
Default Dragging and Dropping


Hi,

I'm trying to make a part of a program, but I'm just getting really stuck.

I need to be able to drag and drop jpeg files into image (or picture but preferably image) boxes from windows explorer.

Can anyone help?

Thanks,

Adrian Osmond.
Reply With Quote
  #2  
Old 11-22-2002, 09:47 AM
DeadalusDragging and Dropping Deadalus is offline
Promising Talent

Retired Moderator
* Guru *
 
Join Date: May 2002
Location: Brussels
Posts: 3,601
Default

Put the OleDragMode of the Image control to 1 and use something like this in its OLEDragDrop event:
Code:
Private Sub Image1_OLEDragDrop(Data As DataObject, Effect As Long, _ Button As Integer, Shift As Integer, X As Single, Y As Single) On Error Resume Next If Data.Files.Count <> 0 Then Dim i As Long For i = 1 To Data.Files.Count If Right$(Data.Files.Item(i), 4) = ".jpg" Then Set Image1.Picture = LoadPicture(Data.Files.Item(i)) Exit Sub End If Next i End If End Sub
Of course you can use a control array to do this for all image controls at once.
Hope it helps.
Reply With Quote
  #3  
Old 11-25-2002, 02:00 AM
adrianosmond's Avatar
adrianosmond adrianosmond is offline
Freshman
 
Join Date: Nov 2002
Location: UK
Posts: 48
Default

Thanks!

That does seem to work, but I have a couple of questions about it. What is the data.files thing? And what errors could be generated that means that you need to resume next?

Thanks again,

Adrian Osmond.
Reply With Quote
  #4  
Old 11-25-2002, 02:44 AM
Flyguy's Avatar
FlyguyDragging and Dropping Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,160
Default

The DataObject in this case holds the files names which are dropped from the file explorer onto the control.
Reply With Quote
  #5  
Old 11-25-2002, 06:48 AM
DeadalusDragging and Dropping Deadalus is offline
Promising Talent

Retired Moderator
* Guru *
 
Join Date: May 2002
Location: Brussels
Posts: 3,601
Default

Very fitting that you answered, ArnoutV, I learned this from an example of yours.

Adrian, I used Resume Next to avoid that corrupted files cause errors when picked. I had some in the map I tried it with.
Reply With Quote
  #6  
Old 11-25-2002, 06:54 AM
adrianosmond's Avatar
adrianosmond adrianosmond is offline
Freshman
 
Join Date: Nov 2002
Location: UK
Posts: 48
Default

Thanks everyone,

That pretty much sorts my problem!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Dragging and Dropping
Dragging and Dropping
Dragging and Dropping Dragging and Dropping
Dragging and Dropping
Dragging and Dropping
Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping Dragging and Dropping
Dragging and Dropping
Dragging and Dropping
 
Dragging and Dropping
Dragging and Dropping
 
-->