vb 图片拖动事件

来源:百度知道 编辑:UC知道 时间:2024/05/29 15:59:22
把picture1的图片 拖动 到image1里面去 并且把picture1的图赋到image1里面去。并触发一个事件 msgbox“完成”

Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Image1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)

End Sub

Private Sub Image1_OLECompleteDrag(Effect As Long)

End Sub

Private Sub Image1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

End Sub

Private Sub Image1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)

End Sub

Private Sub Image1_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)

End Sub

Private Sub Image1_OLESetData(Data As DataObject, DataFormat As Integer)

End Sub

Private Sub Image1_OLEStartDrag(Data As DataObject, AllowedEffec

放个picture和image,什么属性都不用改,直接用下面代码,VB6调试通过。Image可以接受任意对象的图片,就是说,如果有两个Pictruebox,都能拖动,那拖哪个就得到哪个的图片。

'放开鼠标才触发,如果要拖过去就触发,用dragOver事件
Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single)
Image1.Picture = Source.Picture '参数Source代表了放在image上的所有正在拖动的控件
set source.Picture = nothing '删除对方的图片
MsgBox "完成"
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Picture1.Drag vbBeginDrag
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Picture1.Drag vbEndDrag
End Sub

直接复制上就好了

Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Picture1.Drag vbBeginDrag

End Sub

Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single)
Set Image1.Picture = Picture1.Picture

End Su