|
-
Feb 3rd, 2000, 11:56 PM
#1
Thread Starter
New Member
I would like to drag and drop a file from Explorer or any other application, to my application, destination being a Rich Text Box.
How could i do that ???
-
Feb 5th, 2000, 08:28 AM
#2
Thread Starter
New Member
Figured it out. I thought I might post it for all who may need it in the future.
Here is some Drag and Drop Code that works:
Make sure the Rich TextBox's OLEDragMode and OLEDropMode are set to manual
Private Sub RichTextBox1_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
' check the format of the data that is being dropped
If Data.GetFormat(vbCFFiles) = True Then
' grab the first file name in the collection of file names
sFileName = Data.Files(1)
' incase it's not a valid file display the error message
On Error GoTo invalidfile
' try to load file
Open sFileName For Input As 1
Do Until (EOF(1) = True)
RichTextBox1.Text = input$(LOF(1), 1)
Loop
Close 1
End If
Exit Sub
invalidfile:
' display the invalid file format message
MsgBox "Invalid File Format!"
End Sub
Private Sub RichTextBox1_OLEDragOver(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
' check the data to see if it is what we will allow. if not so "no drop"
If Data.GetFormat(vbCFFiles) Then
Effect = vbDropEffectCopy And Effect
Else
Effect = vbDropEffectNone
End If
End Sub
Austin Kauffman
NitsuaEnterprises.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|