vb中如何实现文件拖动复制
主要是用控件file时从file1拖住文件复制在file2中如何实现,编码是什么?
答案:给你个例子把:
'''窗体上需要DriveListBox,DirListBox和FileListBox各2个,名称保留默认名称
Option Explicit
Dim fcpy As Boolean '标记是否是从file1托过来的文件
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Dir2_Change()
File2.Path = Dir2.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Drive2_Change()
Dir2.Path = Drive2.Drive
End Sub
Private Sub File1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
fcpy = True
End Sub
Private Sub File2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If fcpy Then '如果为file1托来的
FileCopy Dir1.Path & "\" & File1.FileName, Dir2.Path & "\" & File1.FileName '复制文件
fcpy = False
File2.Refresh '刷新列表
End If
End Sub
Private Sub Form_Load()
File1.OLEDragMode = 1
File1.OLEDropMode = 1
File2.OLEDragMode = 1
File2.OLEDropMode = 1
End Sub