|
发表于 2024-11-20 19:45
来自手机
|
显示全部楼层
Private Sub Form_Load()
Me.OLEDropMode = 1
End Sub
Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim j As Long
If Data.GetFormat(vbCFFiles) = True Then
If Not (GetAttr(Data.Files.Item(1)) And vbDirectory) Then
' To open only one file
' OpenFile(Data.Files.Item(1))
' To open multi files
For j = 1 To Data.Files.Count
' OpenFile(Data.Files.Item(j))
MsgBox Data.Files.Item(j)
Next
End If
End If
End Sub
Private Sub Form_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
If Data.GetFormat(vbCFFiles) = True Then
If (GetAttr(Data.Files.Item(1)) And vbDirectory) Then ' don't accept folders
Effect = vbDropEffectNone
Else
Effect = vbDropEffectCopy
End If
End If
End Sub
https://www.vbforums.com/showthread.php?722153-Allowing-a-Visual-Basic-Application-to-Accept-Drag-and-Drop-Files |
|