- 猫帽
-
在窗体上添加一个imagebox,加上图片
Option Explicit
Dim xx As Single, yy As Single
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X: yy = Y
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Image1.Move Image1.Left + X - xx, Image1.Top + Y - yy
End Sub
就这样
- 侠客
-
我按照你的要求制作了源程序例子,请下载:http://www.fileurls.com/download.ashx?id=smagxq
- 余辉
-
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Button = 1
xp = x
yp = y
Image1.MousePointer = 7
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If xp <> 0 And yp <> 0 Then
Image1.Left = Image1.Left + (x - xp)
Image1.Top = Image1.Top + (y - yp)
End If
xz = Image1.Left
yz = Image1.Top
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Button = 1
xp = yp = 0
Image1.MousePointer = 0
End Sub
这个是拖拽部分的源码
不知道你具体需要什么 因为拖拽过程中还存在一些细节问题 比如:
图片是否放大缩小?
是否需要锁定拖拽范围?
- 还要旺仔
-
以下是相关的代码,VB6.0
Private DX As Single, DY As Single, PX As Single, PY As Single "鼠标拖拽效果用的变量
Private NowDrow As Long
"鼠标拖拽效果
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
PX = X: PY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Cls
If NowDrow = 1 Then
Me.PaintPicture oLab, DX + X - PX, DY + Y - PY
Else
Me.PaintPicture oPic, DX + X - PX, DY + Y - PY
End If
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
DX = DX + X - PX: DY = DY + Y - PY
End Sub
- 寻云
-
说详细点